Changeset 5747 for ndgCommon


Ignore:
Timestamp:
22/09/09 12:51:04 (10 years ago)
Author:
sdonegan
Message:

takes discoveryService api url as optional argument to replaced hardcoded and P.I.A. discoveyURL previously

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/dal/ndgRetrieve.py

    r5184 r5747  
    3636        calls to retrieveDoc()  
    3737        ''' 
     38         
    3839        logging.info("Instantiating NDGRetrieve") 
     40         
    3941        self.config = config 
    4042        self.__getEXistConfigData() 
    4143        self.useRemoteEXist = useRemoteEXist 
    4244        self.useDiscovery = useDiscovery 
     45         
    4346        logging.info("NDGRetrieve instantiated") 
    4447 
    4548     
    46     def __getClient(self, ndgObject, useRemoteEXist, useDiscovery): 
     49    def __getClient(self, ndgObject, useRemoteEXist, useDiscovery, discoveryServiceURL=None): 
    4750        '''  
    4851        Set up the client to the retrieve the ndg doc - NB, this can be 
     
    5457        @param useDiscovery: if True, AND the schema is one of [DIF,MDIP,or ISO] 
    5558        use the discovery ws to retrieve ndg docs 
     59        @param discoveryServiceURL: optional param for discoveryService API URL 
    5660        ''' 
    5761        logging.debug("Getting approprate connection to retrieve document") 
     62         
    5863        if useRemoteEXist and useDiscovery: 
    5964            raise ValueError('Invalid options to NDGRetrieve (useRemoteEXist AND useDiscovery impossible)') 
    6065         
    6166        if useDiscovery: 
    62             return self.__getDiscoveryClient(ndgObject) 
     67            return self.__getDiscoveryClient(ndgObject, discoveryServiceURL) 
    6368 
    6469        return self.__getEXistClient(ndgObject, useRemoteEXist) 
    6570 
    6671 
    67     def __getDiscoveryClient(self, ndgObject): 
     72    def __getDiscoveryClient(self, ndgObject, discoveryServiceURL=None): 
    6873        ''' 
    6974        Return discovery client, if appropriate, for retrieving ndgObject 
    7075        @param ndgObject: ndgObject associated with doc to retrieve 
     76        @param discoveryServiceURL: optional parameter stating the API to use.  If none, discoverService will default to value in discoveryServiceClient.py 
    7177        @raise NDGRetrieveError if object not of appropriate schema to use 
    7278        the discovery service for 
     
    7581        logging.debug("Getting Discovery service client") 
    7682        if ndgObject.schema in no.DISCOVERY_SCHEMES: 
    77             client =  DiscoveryServiceClient() 
     83             
     84            client =  DiscoveryServiceClient(None,discoveryServiceURL) 
    7885            logging.debug("- returning discovery service client") 
    7986            return client 
     
    143150 
    144151    def retrieveDoc(self, ndgObject, outputFormat = None, 
    145                     useRemoteEXist = None, useDiscovery = None, filterAtoms = False): 
     152                    useRemoteEXist = None, useDiscovery = None, filterAtoms = False, discoveryServiceURL = None): 
    146153        ''' 
    147154        Retrieve the doc represented by the specified ndgURI in the specified format 
     
    162169        doc in string format 
    163170        ''' 
     171         
     172         
    164173        logging.info("Retrieving NDG doc with URI, %s" %ndgObject) 
    165174        # allow users to adjust retrieval settings on a per retrieval basis 
     
    172181            discovery = useDiscovery 
    173182             
    174         client = self.__getClient(ndgObject, remote, discovery) 
     183         
     184             
     185        client = self.__getClient(ndgObject, remote, discovery, discoveryServiceURL) 
    175186       
    176187        if ndgObject.schema==no.NDGA0_DOC_TYPE: 
Note: See TracChangeset for help on using the changeset viewer.