Changeset 1879


Ignore:
Timestamp:
15/12/06 16:47:00 (13 years ago)
Author:
lawrence
Message:

Version of discovery running off the Hermes wsdl (simpler interfaces)

Location:
TI07-MOLES/trunk/PythonCode/browse/portal/cgi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse/ndgSearch.py

    r1870 r1879  
    2626        #how do we get a different backend provider? 
    2727        loc=DiscoveryServiceLocator() 
    28         self.server=loc.getDiscovery(readerclass=ExpatReaderClass, 
     28        #self.server=loc.getDiscovery(readerclass=ExpatReaderClass, 
     29        self.server=loc.getDiscoveryServicePortType(readerclass=ExpatReaderClass, 
    2930        tracefile=sys.stdout) 
    3031        self.documents=None 
     
    3940         
    4041         
    41         if target=='Authors': 
    42             request=doAuthorSearchRequest() 
    43         elif target=='Params': 
    44             request=doParameterSearchRequest() 
    45         else: 
    46             request=doFullTextSearchRequest() 
     42        #if target=='Authors': 
     43        #    request=doAuthorSearchRequest() 
     44        #elif target=='Params': 
     45        #    request=doParameterSearchRequest() 
     46        #else: 
     47        #    request=doFullTextSearchRequest() 
     48        request=doSearchRequest() 
    4749        request.Term=term 
    4850        request.Start=start 
    4951        request.HowMany=howmany 
     52        request.TermType={'Authors':'author','Params':'parameter','All':'fullText'}[target] 
    5053        if bbox is not None: 
    5154            box=request.new_BoundingBox() 
     
    6669 
    6770        if self.logger: itime=time.time() 
     71        response=self.server.doSearch(request) 
    6872        #try: 
    69         if target=='All': 
    70             response=self.server.doFullTextSearch(request) 
    71         elif target=='Authors': 
    72             response=self.server.doAuthorSearch(request) 
    73         elif target=='Params': 
    74             response=self.server.doParameterSearch(request) 
    75         else: 
    76             self.error=('Unknown search target type (%s)'%target,'programming error in backend') 
    77             return  
     73        #if target=='All': 
     74        #    response=self.server.doFullTextSearch(request) 
     75        #elif target=='Authors': 
     76        #    response=self.server.doAuthorSearch(request) 
     77        #elif target=='Params': 
     78        #    response=self.server.doParameterSearch(request) 
     79        #else: 
     80        #    self.error=('Unknown search target type (%s)'%target,'programming error in backend') 
     81        #    return  
    7882        #except Exception,e: 
    7983        #   raise Exception,e 
  • TI07-MOLES/trunk/PythonCode/browse/portal/cgi/discovery/DiscoveryService_services.py

    r1868 r1879  
    1414# Locator 
    1515class DiscoveryServiceLocator: 
    16     Discovery_address = "http://glue.badc.rl.ac.uk/axis2/services/DiscoveryService" 
    17     def getDiscoveryAddress(self): 
    18         return DiscoveryServiceLocator.Discovery_address 
    19     def getDiscovery(self, url=None, **kw): 
    20         return DiscoverySoapBindingSOAP(url or DiscoveryServiceLocator.Discovery_address, **kw) 
     16    DiscoveryServicePortType_address = "http://hermes.neodc.rl.ac.uk:8080/axis2/services/DiscoveryService" 
     17    def getDiscoveryServicePortTypeAddress(self): 
     18        return DiscoveryServiceLocator.DiscoveryServicePortType_address 
     19    def getDiscoveryServicePortType(self, url=None, **kw): 
     20        return DiscoveryServiceSOAP11BindingSOAP(url or DiscoveryServiceLocator.DiscoveryServicePortType_address, **kw) 
    2121 
    2222# Methods 
    23 class DiscoverySoapBindingSOAP: 
     23class DiscoveryServiceSOAP11BindingSOAP: 
    2424    def __init__(self, url, **kw): 
    2525        kw.setdefault("readerclass", None) 
     
    2929        # no ws-addressing 
    3030 
    31     # op: doFullTextSearch 
    32     def doFullTextSearch(self, request): 
    33         if isinstance(request, doFullTextSearchRequest) is False: 
    34             raise TypeError, "%s incorrect request type" % (request.__class__) 
    35         kw = {} 
    36         # no input wsaction 
    37         self.binding.Send(None, None, request, soapaction="None", **kw) 
    38         # no output wsaction 
    39         response = self.binding.Receive(doFullTextSearchResponse.typecode) 
    40         return response 
    41  
    42     # op: doAuthorSearch 
    43     def doAuthorSearch(self, request): 
    44         if isinstance(request, doAuthorSearchRequest) is False: 
    45             raise TypeError, "%s incorrect request type" % (request.__class__) 
    46         kw = {} 
    47         # no input wsaction 
    48         self.binding.Send(None, None, request, soapaction="None", **kw) 
    49         # no output wsaction 
    50         response = self.binding.Receive(doAuthorSearchResponse.typecode) 
    51         return response 
    52  
    53     # op: doParameterSearch 
    54     def doParameterSearch(self, request): 
    55         if isinstance(request, doParameterSearchRequest) is False: 
    56             raise TypeError, "%s incorrect request type" % (request.__class__) 
    57         kw = {} 
    58         # no input wsaction 
    59         self.binding.Send(None, None, request, soapaction="None", **kw) 
    60         # no output wsaction 
    61         response = self.binding.Receive(doParameterSearchResponse.typecode) 
    62         return response 
    63  
    64     # op: doPresent 
    65     def doPresent(self, request): 
    66         if isinstance(request, doPresentRequest) is False: 
    67             raise TypeError, "%s incorrect request type" % (request.__class__) 
    68         kw = {} 
    69         # no input wsaction 
    70         self.binding.Send(None, None, request, soapaction="None", **kw) 
    71         # no output wsaction 
    72         response = self.binding.Receive(doPresentResponse.typecode) 
    73         return response 
    74  
    7531    # op: getListNames 
    7632    def getListNames(self, request): 
     
    7935        kw = {} 
    8036        # no input wsaction 
    81         self.binding.Send(None, None, request, soapaction="None", **kw) 
     37        self.binding.Send(None, None, request, soapaction="urn:DiscoveryServiceAPI:Discovery:getListNamesRequest", **kw) 
    8238        # no output wsaction 
    8339        response = self.binding.Receive(getListNamesResponse.typecode) 
     
    9046        kw = {} 
    9147        # no input wsaction 
    92         self.binding.Send(None, None, request, soapaction="None", **kw) 
     48        self.binding.Send(None, None, request, soapaction="urn:DiscoveryServiceAPI:Discovery:getListRequest", **kw) 
    9349        # no output wsaction 
    9450        response = self.binding.Receive(getListResponse.typecode) 
    9551        return response 
    9652 
    97 doFullTextSearchRequest = ns0.doFullTextSearch_Dec().pyclass 
     53    # op: doSearch 
     54    def doSearch(self, request): 
     55        if isinstance(request, doSearchRequest) is False: 
     56            raise TypeError, "%s incorrect request type" % (request.__class__) 
     57        kw = {} 
     58        # no input wsaction 
     59        self.binding.Send(None, None, request, soapaction="urn:DiscoveryServiceAPI:Discovery:doSearchRequest", **kw) 
     60        # no output wsaction 
     61        response = self.binding.Receive(doSearchResponse.typecode) 
     62        return response 
    9863 
    99 doFullTextSearchResponse = ns0.doFullTextSearchReturn_Dec().pyclass 
    100  
    101 doAuthorSearchRequest = ns0.doAuthorSearch_Dec().pyclass 
    102  
    103 doAuthorSearchResponse = ns0.doAuthorSearchReturn_Dec().pyclass 
    104  
    105 doParameterSearchRequest = ns0.doParameterSearch_Dec().pyclass 
    106  
    107 doParameterSearchResponse = ns0.doParameterSearchReturn_Dec().pyclass 
    108  
    109 doPresentRequest = ns0.doPresent_Dec().pyclass 
    110  
    111 doPresentResponse = ns0.doPresentReturn_Dec().pyclass 
     64    # op: doPresent 
     65    def doPresent(self, request): 
     66        if isinstance(request, doPresentRequest) is False: 
     67            raise TypeError, "%s incorrect request type" % (request.__class__) 
     68        kw = {} 
     69        # no input wsaction 
     70        self.binding.Send(None, None, request, soapaction="urn:DiscoveryServiceAPI:Discovery:doPresentRequest", **kw) 
     71        # no output wsaction 
     72        response = self.binding.Receive(doPresentResponse.typecode) 
     73        return response 
    11274 
    11375getListNamesRequest = ns0.getListNames_Dec().pyclass 
     
    11880 
    11981getListResponse = ns0.getListReturn_Dec().pyclass 
     82 
     83doSearchRequest = ns0.doSearch_Dec().pyclass 
     84 
     85doSearchResponse = ns0.doSearchReturn_Dec().pyclass 
     86 
     87doPresentRequest = ns0.doPresent_Dec().pyclass 
     88 
     89doPresentResponse = ns0.doPresentReturn_Dec().pyclass 
  • TI07-MOLES/trunk/PythonCode/browse/portal/cgi/discovery/DiscoveryService_services_types.py

    r1868 r1879  
    4444        def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw): 
    4545            ns = ns0.SearchType_Def.schema 
    46             TClist = [ZSI.TC.String(pname=(ns,"term"), aname="_term", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"start"), aname="_start", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"howMany"), aname="_howMany", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"orderBy"), aname="_orderBy", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","orderByDirectionType",lazy=False)(pname=(ns,"orderByDirection"), aname="_orderByDirection", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"scope"), aname="_scope", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","BoundingBoxType",lazy=False)(pname=(ns,"BoundingBox"), aname="_BoundingBox", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","DateRangeType",lazy=False)(pname=(ns,"DateRange"), aname="_DateRange", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
     46            TClist = [ZSI.TC.String(pname=(ns,"term"), aname="_term", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"termType"), aname="_termType", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"start"), aname="_start", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"howMany"), aname="_howMany", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"orderBy"), aname="_orderBy", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","orderByDirectionType",lazy=False)(pname=(ns,"orderByDirection"), aname="_orderByDirection", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"scope"), aname="_scope", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","BoundingBoxType",lazy=False)(pname=(ns,"BoundingBox"), aname="_BoundingBox", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","DateRangeType",lazy=False)(pname=(ns,"DateRange"), aname="_DateRange", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
    4747            self.attribute_typecode_dict = attributes or {} 
    4848            if extend: TClist += ofwhat 
     
    5555                    # pyclass 
    5656                    self._term = None 
     57                    self._termType = None 
    5758                    self._start = None 
    5859                    self._howMany = None 
     
    137138        def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw): 
    138139            ns = ns0.getListNamesReturnType_Def.schema 
    139             TClist = [self.__class__.listNames_Dec(minOccurs=1, maxOccurs="unbounded", nillable=False, encoded=kw.get("encoded"))] 
    140             self.attribute_typecode_dict = attributes or {} 
    141             if extend: TClist += ofwhat 
    142             if restrict: TClist = ofwhat 
    143             ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw) 
    144             class Holder: 
    145                 __metaclass__ = pyclass_type 
    146                 typecode = self 
    147                 def __init__(self): 
    148                     # pyclass 
    149                     self._listNames = [] 
     140            TClist = [self.__class__.listNames_Dec(minOccurs=1, maxOccurs=1, nillable=False, encoded=kw.get("encoded"))] 
     141            self.attribute_typecode_dict = attributes or {} 
     142            if extend: TClist += ofwhat 
     143            if restrict: TClist = ofwhat 
     144            ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw) 
     145            class Holder: 
     146                __metaclass__ = pyclass_type 
     147                typecode = self 
     148                def __init__(self): 
     149                    # pyclass 
     150                    self._listNames = None 
    150151                    return 
    151152            Holder.__name__ = "getListNamesReturnType_Holder" 
     
    295296            self.pyclass = Holder 
    296297 
    297     class doAuthorSearch_Dec(ElementDeclaration): 
    298         literal = "doAuthorSearch" 
    299         schema = "urn:DiscoveryServiceAPI" 
    300         def __init__(self, **kw): 
    301             kw["pname"] = ("urn:DiscoveryServiceAPI","doAuthorSearch") 
    302             kw["aname"] = "_doAuthorSearch" 
    303             if ns0.SearchType_Def not in ns0.doAuthorSearch_Dec.__bases__: 
    304                 bases = list(ns0.doAuthorSearch_Dec.__bases__) 
     298    class doSearch_Dec(ElementDeclaration): 
     299        literal = "doSearch" 
     300        schema = "urn:DiscoveryServiceAPI" 
     301        def __init__(self, **kw): 
     302            kw["pname"] = ("urn:DiscoveryServiceAPI","doSearch") 
     303            kw["aname"] = "_doSearch" 
     304            if ns0.SearchType_Def not in ns0.doSearch_Dec.__bases__: 
     305                bases = list(ns0.doSearch_Dec.__bases__) 
    305306                bases.insert(0, ns0.SearchType_Def) 
    306                 ns0.doAuthorSearch_Dec.__bases__ = tuple(bases) 
     307                ns0.doSearch_Dec.__bases__ = tuple(bases) 
    307308 
    308309            ns0.SearchType_Def.__init__(self, **kw) 
    309             if self.pyclass is not None: self.pyclass.__name__ = "doAuthorSearch_Dec_Holder" 
    310  
    311     class doFullTextSearch_Dec(ElementDeclaration): 
    312         literal = "doFullTextSearch" 
    313         schema = "urn:DiscoveryServiceAPI" 
    314         def __init__(self, **kw): 
    315             kw["pname"] = ("urn:DiscoveryServiceAPI","doFullTextSearch") 
    316             kw["aname"] = "_doFullTextSearch" 
    317             if ns0.SearchType_Def not in ns0.doFullTextSearch_Dec.__bases__: 
    318                 bases = list(ns0.doFullTextSearch_Dec.__bases__) 
    319                 bases.insert(0, ns0.SearchType_Def) 
    320                 ns0.doFullTextSearch_Dec.__bases__ = tuple(bases) 
    321  
    322             ns0.SearchType_Def.__init__(self, **kw) 
    323             if self.pyclass is not None: self.pyclass.__name__ = "doFullTextSearch_Dec_Holder" 
    324  
    325     class doParameterSearch_Dec(ElementDeclaration): 
    326         literal = "doParameterSearch" 
    327         schema = "urn:DiscoveryServiceAPI" 
    328         def __init__(self, **kw): 
    329             kw["pname"] = ("urn:DiscoveryServiceAPI","doParameterSearch") 
    330             kw["aname"] = "_doParameterSearch" 
    331             if ns0.SearchType_Def not in ns0.doParameterSearch_Dec.__bases__: 
    332                 bases = list(ns0.doParameterSearch_Dec.__bases__) 
    333                 bases.insert(0, ns0.SearchType_Def) 
    334                 ns0.doParameterSearch_Dec.__bases__ = tuple(bases) 
    335  
    336             ns0.SearchType_Def.__init__(self, **kw) 
    337             if self.pyclass is not None: self.pyclass.__name__ = "doParameterSearch_Dec_Holder" 
     310            if self.pyclass is not None: self.pyclass.__name__ = "doSearch_Dec_Holder" 
    338311 
    339312    class doPresent_Dec(ElementDeclaration): 
     
    373346            if self.pyclass is not None: self.pyclass.__name__ = "getList_Dec_Holder" 
    374347 
    375     class doAuthorSearchReturn_Dec(ElementDeclaration): 
    376         literal = "doAuthorSearchReturn" 
    377         schema = "urn:DiscoveryServiceAPI" 
    378         def __init__(self, **kw): 
    379             kw["pname"] = ("urn:DiscoveryServiceAPI","doAuthorSearchReturn") 
    380             kw["aname"] = "_doAuthorSearchReturn" 
    381             if ns0.SearchReturnType_Def not in ns0.doAuthorSearchReturn_Dec.__bases__: 
    382                 bases = list(ns0.doAuthorSearchReturn_Dec.__bases__) 
     348    class doSearchReturn_Dec(ElementDeclaration): 
     349        literal = "doSearchReturn" 
     350        schema = "urn:DiscoveryServiceAPI" 
     351        def __init__(self, **kw): 
     352            kw["pname"] = ("urn:DiscoveryServiceAPI","doSearchReturn") 
     353            kw["aname"] = "_doSearchReturn" 
     354            if ns0.SearchReturnType_Def not in ns0.doSearchReturn_Dec.__bases__: 
     355                bases = list(ns0.doSearchReturn_Dec.__bases__) 
    383356                bases.insert(0, ns0.SearchReturnType_Def) 
    384                 ns0.doAuthorSearchReturn_Dec.__bases__ = tuple(bases) 
     357                ns0.doSearchReturn_Dec.__bases__ = tuple(bases) 
    385358 
    386359            ns0.SearchReturnType_Def.__init__(self, **kw) 
    387             if self.pyclass is not None: self.pyclass.__name__ = "doAuthorSearchReturn_Dec_Holder" 
    388  
    389     class doFullTextSearchReturn_Dec(ElementDeclaration): 
    390         literal = "doFullTextSearchReturn" 
    391         schema = "urn:DiscoveryServiceAPI" 
    392         def __init__(self, **kw): 
    393             kw["pname"] = ("urn:DiscoveryServiceAPI","doFullTextSearchReturn") 
    394             kw["aname"] = "_doFullTextSearchReturn" 
    395             if ns0.SearchReturnType_Def not in ns0.doFullTextSearchReturn_Dec.__bases__: 
    396                 bases = list(ns0.doFullTextSearchReturn_Dec.__bases__) 
    397                 bases.insert(0, ns0.SearchReturnType_Def) 
    398                 ns0.doFullTextSearchReturn_Dec.__bases__ = tuple(bases) 
    399  
    400             ns0.SearchReturnType_Def.__init__(self, **kw) 
    401             if self.pyclass is not None: self.pyclass.__name__ = "doFullTextSearchReturn_Dec_Holder" 
    402  
    403     class doParameterSearchReturn_Dec(ElementDeclaration): 
    404         literal = "doParameterSearchReturn" 
    405         schema = "urn:DiscoveryServiceAPI" 
    406         def __init__(self, **kw): 
    407             kw["pname"] = ("urn:DiscoveryServiceAPI","doParameterSearchReturn") 
    408             kw["aname"] = "_doParameterSearchReturn" 
    409             if ns0.SearchReturnType_Def not in ns0.doParameterSearchReturn_Dec.__bases__: 
    410                 bases = list(ns0.doParameterSearchReturn_Dec.__bases__) 
    411                 bases.insert(0, ns0.SearchReturnType_Def) 
    412                 ns0.doParameterSearchReturn_Dec.__bases__ = tuple(bases) 
    413  
    414             ns0.SearchReturnType_Def.__init__(self, **kw) 
    415             if self.pyclass is not None: self.pyclass.__name__ = "doParameterSearchReturn_Dec_Holder" 
     360            if self.pyclass is not None: self.pyclass.__name__ = "doSearchReturn_Dec_Holder" 
    416361 
    417362    class doPresentReturn_Dec(ElementDeclaration): 
Note: See TracChangeset for help on using the changeset viewer.