Changeset 4555 for exist/trunk


Ignore:
Timestamp:
08/12/08 09:24:00 (11 years ago)
Author:
cbyrom
Message:

Move existbdclient to lib package + extend to make use of DocumentRetrieve? to allow retrieval of atoms by ID + fix handling of
authors vs contributors when doing Atom to XML exports.

Location:
exist/trunk/python/ndgUtils
Files:
1 added
1 deleted
4 edited

Legend:

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

    r4532 r4555  
    3131 
    3232    ATOM_TYPE = 'ATOM-TYPE' 
     33    ATOM = 'ATOM' 
    3334    def __init__(self, repository, pwfile='passwords.txt'): 
    3435        logging.info("Using repository, '%s'" %repository) 
     
    4041        self.knownQueries={'DIF':'moles2dif','DC':'moles2DC','ISO19139':'moles2iso19139', \ 
    4142                           'NDG-B0':'moles','NDG-B1':'molesObjectType','MDIP':'moles2mdip', \ 
    42                            'NDG-A0':'csml','NumSim':'numsim', 'ATOM':'atom', \ 
     43                           'NDG-A0':'csml','NumSim':'numsim', self.ATOM:'atom', \ 
    4344                           'ATOM-BACKUP':'atom', self.ATOM_TYPE:'atomTypeList'} 
    4445 
     
    6364 
    6465 
    65     def get(self,repository,schema,localID,targetCollection='/db/discovery/moles', includeDocNameData=False): 
     66    def get(self,repository,schema,localID,targetCollection='/db/discovery/moles', \ 
     67            includeDocNameData=False): 
    6668        ''' 
    6769        @keyword includeDocNameData: if True, a dictionary is returned, instead of the dataset, with the key 
  • exist/trunk/python/ndgUtils/lib/existatomvalidator.py

    r4511 r4555  
    77''' 
    88import os, sys, getopt, logging 
    9 import ndgUtils.models.existdbclient as edc 
     9import ndgUtils.lib.existdbclient as edc 
    1010from ndgUtils.vocabtermdata import VocabTermData as VTD 
    1111from ndgUtils.models.Atom import Atom 
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4535 r4555  
    499499        ''' 
    500500        Add related links in string format - converting to Link objects 
     501        NB, only add the link if it is unique 
     502         
    501503        @param linkVals: string of format, 'uri | title | vocabServerURL' 
    502504        ''' 
    503         self.relatedLinks.append(self.objectify(linkVals, 'relatedLinks')) 
     505        link = self.objectify(linkVals, 'relatedLinks') 
     506        if link not in self.relatedLinks: 
     507            self.relatedLinks.append(link) 
    504508 
    505509 
     
    954958            obj = Link() 
    955959        elif attributeName == "atomAuthors" or attributeName == "authors": 
    956             obj = Person() 
     960            # NB, ensure there is only one author tag - extra authors are contributors 
     961            authorType = Person.AUTHOR_TYPE 
     962            if self.author: 
     963                authorType= Person.CONTRIBUTOR_TYPE 
     964            obj = Person(personType = authorType) 
    957965 
    958966        if obj: 
    959967            obj.fromString(objectVals) 
     968            # NB, need to set it now, just in case we don't set it before coming back 
     969            if attributeName == "authors" and not self.author: 
     970                self.author = obj 
    960971            return obj 
    961972         
     
    10591070        self.contentFile = csmlName 
    10601071        content = csmlContent or csmlName 
     1072     
    10611073        csmlDoc = CsmlParser.Dataset(file=content) 
    10621074         
     
    12041216            for url in urls: 
    12051217                doc = dr.get(type, dr.ATOM_TYPE, url, \ 
    1206                                             targetCollection='/db/atoms/') 
     1218                             targetCollection = eXistConnector.BASE_COLLECTION_PATH) 
    12071219                # now need to turn this results set into actual atoms 
    12081220                tree = ET.fromstring(doc) 
     
    12251237                    localID = link.href.split("__ATOM__")[-1] 
    12261238                    deploymentAtom = dr.get(self.ME.providerID, 'ATOM', localID, \ 
    1227                                             targetCollection='/db/atoms/') 
     1239                                            targetCollection = eXistConnector.BASE_COLLECTION_PATH) 
    12281240     
    12291241                deployment = Deployment.Deployment(Atom(xmlString=str(deploymentAtom))) 
  • exist/trunk/python/ndgUtils/vocabtermdata.py

    r4532 r4555  
    263263    VOCAB_SERVER_URL = 'http://vocab.ndg.nerc.ac.uk/clients/whatLists' 
    264264 
    265 #    BROWSE_ROOT_URL = "http://snow.badc.rl.ac.uk:5000/view/" 
     265    #BROWSE_ROOT_URL = "http://snow.badc.rl.ac.uk:5000/view/" 
    266266    BROWSE_ROOT_URL = "http://localhost:5000/view/" 
    267267 
Note: See TracChangeset for help on using the changeset viewer.