Changeset 6860


Ignore:
Timestamp:
07/05/10 22:58:52 (9 years ago)
Author:
sdonegan
Message:

Added method to find a vocab by just base url with no version number

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/http/vocabserverclient.py

    r5374 r6860  
    8787        ''' 
    8888        logging.debug("Retrieving list info for key, '%s'" %listKey) 
     89         
    8990        url = self.GET_LIST_QUERY%(self.path, listKey) 
    9091        doc = self.readURL(url) 
     
    121122        for record in recordElements: 
    122123            ctr = CodeTableType(et = record) 
     124             
    123125            if ctr.listKey == listKey: 
    124126                logging.debug("- found the specified list - returning data as CodeTableType") 
    125127                return ctr 
    126128             
    127         raise ValueError("Vocab list, '%s' not found" %listKey)         
     129        raise ValueError("Vocab list, '%s' not found" %listKey) 
     130        
     131     
     132    def getListInfoBroadMatch(self, listKey): 
     133        ''' 
     134         
     135        Updated version of getListInfo - needed for dealing with NDG vocab lists - version number is upgraded each time a set of 
     136        entries are accepted so no use keeping explicit version in original VTE config file i.e. vocab.ndg.nerc.ac.uk/list/P071/12 
     137        therefore, drop the version and just use the unique list identifier to match from the whatLists operation... i.e. vocab.ndg.nerc.ac.uk/list/P071 
     138         
     139        Retrieve info on a vocab list 
     140        @param listKey: url of the vocab list 
     141        @raise SystemError: if vocab lookup fails 
     142        @raise ValueError: if no list info found 
     143        @return CodeTableType with data about specified list 
     144        ''' 
     145        logging.debug("Retrieving info on list with key, '%s'" %listKey) 
     146        url = self.WHAT_LISTS_QUERY %(self.path) 
     147        doc = self.readURL(url) 
     148        et = ET.fromstring(doc) 
     149 
     150        error = et.findtext('{%s}error' %ndgObject.VOCAB_NS) 
     151        if error != 'false': 
     152            raise SystemError("Problem occurred whilst looking up vocab list: %s" %error) 
     153 
     154        recordElements = et.findall('{%s}codeTableType' %ndgObject.VOCAB_NS) 
     155         
     156        for record in recordElements: 
     157            ctr = CodeTableType(et = record) 
     158             
     159            if listKey in ctr.listKey: 
     160                logging.debug("- found a matching list root - returning data as CodeTableType") 
     161                return ctr 
     162             
     163        raise ValueError("Vocab list, '%s' not found" %listKey)       
    128164         
    129165         
Note: See TracChangeset for help on using the changeset viewer.