Changeset 5170 for ndgCommon/trunk


Ignore:
Timestamp:
06/04/09 10:04:08 (10 years ago)
Author:
cbyrom
Message:

Adjust atom retrieval code to allow filtering of atoms in the 'working'
state - NB, when in browse mode, these atoms should not be available
for display.

Location:
ndgCommon/trunk/ndg/common
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/searchclient.py

    r5134 r5170  
    137137                if not summary.findtext('href'): 
    138138                    continue 
    139                 for key in ['providerID', 'created', 'href', 'subtype']: 
     139                for key in ['providerID', 'created', 'href', 'subtype', 'collection']: 
    140140                    t[key] = summary.findtext(key) 
    141141 
     
    144144                        t['editLink'] = t[key].replace('view', 'editAtom') 
    145145                         
    146                     if key == 'subtype': 
    147                         t[key] = t[key] 
    148                  
    149146            self.results.append(t) 
    150147        return self.results 
     
    186183<id>{$DE/atom:id/text()}</id> \ 
    187184<name>{$DE/atom:title/text()}</name> \ 
     185<collection>{util:collection-name($DE)}</collection> \ 
    188186<type>{string($DE/atom:category[@term='ATOM_TYPE']/@scheme)}</type> \ 
    189187<subtype>{string($DE/atom:category[@term='ATOM_SUBTYPE']/@scheme)}</subtype> \ 
  • ndgCommon/trunk/ndg/common/src/dal/ndgRetrieve.py

    r5009 r5170  
    140140        self.pwf= self.config.get('NDG_EXIST','passwordFile') 
    141141        self.proxyServer = self.config.get('DEFAULT','proxyServer') 
    142          
    143142 
    144143 
    145144    def retrieveDoc(self, ndgObject, outputFormat = None, 
    146                     useRemoteEXist = None, useDiscovery = None): 
     145                    useRemoteEXist = None, useDiscovery = None, filterAtoms = False): 
    147146        ''' 
    148147        Retrieve the doc represented by the specified ndgURI in the specified format 
     
    158157        - also, note, these are just the default values; they can be overridden on  
    159158        calls to retrieveDoc()  
     159        @keyword filterAtoms: if True, remove any atoms in the Working state - NB, these 
     160        should not be visible in 'browse' mode  
    160161        @return: status, doc: status = 0 if fails, or 1 if succeeds. doc = retrieved 
    161162        doc in string format 
     
    198199            time2 = time.time()-time1 
    199200            logging.info('Document retrieve [%s] took [%s]'%(ndgObject, time2)) 
     201             
     202            if doc and filterAtoms: 
     203                xq = client.resources.xq['atomFullPath'] 
     204                 
     205                # set the query up with the correct target collection 
     206                xq=xq.replace('TargetCollection', target) 
     207                xq=xq.replace('RepositoryID',ndgObject.repository) 
     208                xq=xq.replace('LocalID',ndgObject.localID) 
     209                docPath = client.client.runQuery(xq) 
     210                if docPath[0].find('/db/atoms/working') > -1: 
     211                    doc = "Document unavailable for view" 
     212                    return 0, doc 
     213                 
    200214        except Exception,e: 
    201215            error = str(e) 
  • ndgCommon/trunk/ndg/common/src/lib/atomvalidator.py

    r4964 r5170  
    1111 @author: C Byrom, Tessella Nov 2008 
    1212''' 
    13 import logging, traceback, datetime, xmlrpclib, socket 
     13import logging, traceback, datetime, xmlrpclib, socket, urllib 
    1414from ndg.common.src.clients.xmldb.eXist.atomclient import AtomClient 
    1515from ndg.common.src.models.vocabtermdata import isValidTermURI 
     
    276276            if link.hasValue(): 
    277277                try: 
     278                    # unquote the link, just in case it has been encoded 
     279                    url = urllib.unquote(link.href) 
    278280                    # don't lookup link, if it has already been validated before 
    279                     if link.href in self._validLinks: 
     281                    if url in self._validLinks: 
    280282                        continue 
    281283                     
    282                     if link.href in invalidLinks or not simpleURLCheck(link.href): 
    283                         self.__addError(self.BROKEN_LINKS, "Broken link: '%s'" %link.href) 
    284                         if link.href not in invalidLinks: 
    285                             invalidLinks.append(link.href) 
     284                    if url in invalidLinks or not simpleURLCheck(url): 
     285                        self.__addError(self.BROKEN_LINKS, "Broken link: '%s'" %url) 
     286                        if url not in invalidLinks: 
     287                            invalidLinks.append(url) 
    286288                    else: 
    287                         self._validLinks.append(link.href) 
     289                        self._validLinks.append(url) 
    288290                         
    289291                except Exception, e: 
  • ndgCommon/trunk/ndg/common/src/models/Atom.py

    r5136 r5170  
    44 @author: C Byrom, Tessella Jun 2008 
    55''' 
    6 import sys, logging, re, datetime 
     6import sys, logging, re, datetime, urllib 
    77from xml.etree import cElementTree as ET 
    88import csml.parser as CsmlParser 
     
    381381         
    382382        newLinks.extend(links) 
     383        for link in newLinks: 
     384           link.href = urllib.quote(link.href, '%') 
    383385        self.relatedLinks = newLinks 
    384386        logging.debug("Online references added") 
  • ndgCommon/trunk/ndg/common/xmldb/xquery/atomFullPath.xq

    r4968 r5170  
    44declare variable $targetCollection as xs:string := 'TargetCollection'; 
    55declare variable $localIdentifier as xs:string := 'RepositoryID__ATOM__LocalID$'; 
    6 declare variable $repositoryIdentifier as xs:string := 'RepositoryID'; 
    76for $DE in collection($targetCollection)/entry[matches(id, $localIdentifier)]  
    87return  
Note: See TracChangeset for help on using the changeset viewer.