Ignore:
Timestamp:
18/05/09 17:22:02 (12 years ago)
Author:
cbyrom
Message:

Extend the discovery ws client to allow access to the getListNames and
getList methods + add tests to these + extend search method to include
the orderBy and orderDirection parameters. NB, there is a bug in the
getListNames code which means that the getListNameRequest object
cannot be created, so the method cannot be invoked - presumably this
is an error due to the wsdl2python generation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/ws/discovery/discoveryserviceclient.py

    r5006 r5304  
    5656        self.status=None 
    5757     
    58     def search(self,term,start=1,howmany=20,target='All', 
    59                scope=None,bbox=None,dateRange=None,geoSearchType='overlaps'): 
     58    def search(self, term, start=1, howmany=20, target='All', 
     59               scope=None, bbox=None, dateRange=None, 
     60               geoSearchType='overlaps', orderBy = None, orderDirection = None): 
    6061        '''  
    6162        Get a list of documents, with basic summary info for each doc, for a  
     
    8182        request.Start=start 
    8283        request.HowMany=howmany 
     84        if orderBy: 
     85            request.set_element_orderBy(orderBy) 
     86 
     87        if orderDirection: 
     88            request.set_element_orderByDirection(orderDirection) 
     89 
    8390        request.TermType={'Authors':'author','Params':'parameter','All':'fullText'}[target] 
    8491        if bbox is not None: 
     
    139146        logging.debug("Request object set up") 
    140147        return request 
     148 
     149 
     150    def getListNames(self): 
     151        ''' 
     152        Get the various list names used by the web service 
     153        @return list with all the different listnames in 
     154        ''' 
     155        logging.debug("Getting list names from discovery webservice") 
     156        # TODO: this current doesn't work - must be an error in the wsdl2python 
     157        # code generation.... 
     158        request = getListNamesRequest() 
     159 
     160        names = self.server.getListNames(request) 
     161         
     162        logging.debug("- returning list names") 
     163        return result 
     164 
     165 
     166    def getList(self, listName): 
     167        ''' 
     168        Get the values for the specified list 
     169        @param listName: name of list to retrieve values for 
     170        @return list with the data for the specified list 
     171        ''' 
     172        logging.debug("Getting data for list '%s'" %listName) 
     173        request = getListRequest() 
     174        request.set_element_listName(listName) 
     175 
     176        results = self.server.getList(request) 
     177        listData = results.get_element_list().get_element_listMember() 
     178         
     179        logging.debug("- returning list names") 
     180        return listData 
    141181 
    142182 
Note: See TracChangeset for help on using the changeset viewer.