Changeset 3158 for exist


Ignore:
Timestamp:
17/12/07 14:28:17 (12 years ago)
Author:
lawrence
Message:

... and support for creation dates of objects as well ...

Location:
exist/trunk/python/ndgUtils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/__init__.py

    r3147 r3158  
    1212from ndgObject import ndgObject 
    1313from ndgSearch import ndgSearch 
     14from ndgDirectory import ndgDirectory 
  • exist/trunk/python/ndgUtils/ndgDirectory.py

    r3156 r3158  
    4545        #Use the fact that we know its document name ... 
    4646        fn='%s.xml'%uri 
    47         print fn 
    4847        return self.xmldb.getDoc(self.targetCollection,fn) 
     48     
     49    def created(self,uri=None): 
     50        ''' Return the creation date of the collection (if uri is None), or 
     51        of the specific member within the collection ''' 
     52        q="'%s'"%self.targetCollection 
     53        if uri is not None: q+=",'%s.xml'"%uri 
     54        xq="<created>{xmldb:created(%s)}</created>"%q 
     55        r=self.xmldb.executeChunkedQuery(xq,1,1) 
     56        e=ET.fromstring(str(r)) 
     57        return e.findtext('created') 
     58        
     59         
    4960         
    5061        
  • exist/trunk/python/ndgUtils/test_ndgDirectory.py

    r3156 r3158  
    66     
    77    def setUp(self):  
    8         pass     
     8        tc='/db/discovery/original/DIF/badc.nerc.ac.uk' 
     9        host='glue.badc.rl.ac.uk' 
     10        self.ndgDir=ndgDirectory(tc,host,docType='DIF') 
    911     
    1012    def testDirectory(self): 
    1113        ''' Test the ability to get members of a directory and the first one of them ''' 
    12         tc='/db/discovery/original/DIF/badc.nerc.ac.uk' 
    13         host='glue.badc.rl.ac.uk' 
    14         ndgDir=ndgDirectory(tc,host,docType='DIF') 
    15         print ndgDir.members 
    16         doc=ndgDir.get(ndgDir.members[0]) 
     14        print self.ndgDir.members 
     15        doc=self.ndgDir.get(self.ndgDir.members[0]) 
    1716        print doc 
     17         
     18    def testCreationDates(self): 
     19        '''Test the creation information''' 
     20        print self.ndgDir.created() 
     21        print self.ndgDir.created(self.ndgDir.members[0]) 
    1822         
    1923 
Note: See TracChangeset for help on using the changeset viewer.