Changeset 5208 for ndgCommon


Ignore:
Timestamp:
21/04/09 14:56:22 (10 years ago)
Author:
cbyrom
Message:

Add additional check in atom validator, when dealing with broken links

  • these may refer to docs in the 'working' state, which aren't

available via browse - hence the broken link. For these, allow the
use of an alternative MILK server.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/lib/atomvalidator.py

    r5195 r5208  
    1414from xml.sax.saxutils import unescape 
    1515from ndg.common.src.clients.xmldb.eXist.atomclient import AtomClient 
    16 from ndg.common.src.models.vocabtermdata import isValidTermURI 
     16from ndg.common.src.models.vocabtermdata import isValidTermURI, VocabTermData as VTD 
    1717from ndg.common.src.models.Atom import Atom 
    1818from ndg.common.src.lib.utilities import isValidUnicode, simpleURLCheck, strftime 
     
    5757         
    5858    def __init__(self, atom, atomClient = None,  
     59                 localMILKServer = None, 
    5960                 dbHostName = 'chinook.badc.rl.ac.uk', 
    6061                 dbConfigFile = None,  
     
    6566        Set up validator object - with atom to validate 
    6667        @param atom: Atom object to validate 
     68        @keyword localMILKServer: When validating links, if these are browse related 
     69        these may sometimes fail - since the browse instance will not resolve docs 
     70        in the 'working' state - if the validator is being used, e.g. as part of an 
     71        editor stack, specify the server name - e.g. 'http://localhost:5000' here 
     72        and, if the browse lookup fails, it will be repeated with this server as well 
    6773        @keyword atomClient: an eXist client implementing the InterfaceXMLDBAtomClient interface 
    6874        @keyword dbConfigFile: config file to use with eXist DB connection 
     
    8086        self._isDebug = isDebug 
    8187         
     88        self.localMILKServer = localMILKServer 
    8289        # collections to effectively cache positive results - to avoid multiple 
    8390        # (time consuming) lookups of the same data 
     
    290297                        continue 
    291298                     
    292                     if url in invalidLinks or not simpleURLCheck(url): 
     299                    isValid = simpleURLCheck(url) 
     300                    # NB, if we can't find it, it may just be that we're looking for 
     301                    # a browse doc in the 'working' state - retry with a local instance 
     302                    # of the browse service 
     303                    if not isValid and self.localMILKServer and url.startswith(VTD.BROWSE_SERVER_URL): 
     304                        isValid = simpleURLCheck(url.replace(VTD.BROWSE_SERVER_URL,  
     305                                                             self.localMILKServer)) 
     306                         
     307                    if url in invalidLinks or not isValid: 
    293308                        self.__addError(self.BROKEN_LINKS, "Broken link: '%s'" %url) 
    294309                        if url not in invalidLinks: 
Note: See TracChangeset for help on using the changeset viewer.