Changeset 2422
- Timestamp:
- 20/04/07 08:12:11 (14 years ago)
- Location:
- TI07-MOLES/trunk/PythonCode/wsgi
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/PythonCode/wsgi/DIF.py
r2417 r2422 9 9 from renderEntity import renderEntity 10 10 from ServiceBinding import DIFService 11 from ndgObject import ndgObject 11 12 try: #python 2.5 12 13 from xml.etree import ElementTree as ET … … 36 37 note ... not a complete implementation, currently minimum to 37 38 show a reasonable piece of content ''' 38 def __init__(self,xml,et=0,debug=0,ndgObj ect=None):39 def __init__(self,xml,et=0,debug=0,ndgObj=None): 39 40 40 41 '''Initialise a python dif instance based on an xml document (expected … … 61 62 62 63 # if this is an ndgObject that'll have been sorted externally ... 63 self.ndgObject=ndgObj ect64 self.ndgObject=ndgObj 64 65 65 66 # now try and interpret it … … 158 159 helper.getText(item,'URL'), 159 160 helper.getText(item,'Description') )) 160 161 161 162 if self.ndgObject is None: 162 163 self.binding=None … … 164 165 if self.ndgObject.discoveryURL is not None: 165 166 self.binding=DIFService('DISCOVERY',self.ndgObject.discoveryURL,'Discovery record') 167 #explicitly do late binding on NDG-B URL 168 #... and override contents in metadatarecord 169 print '1' 170 B='%s__%s__%s'%(self.ndgObject.repository,'NDG-B1',self.ndgObject.localID) 171 Bobject=ndgObject(B,config=self.ndgObject.config) 172 print '2' 173 bdone=0 174 if Bobject.gettable!=-1: 175 for s in self.services: 176 print '3 ',s.contentType 177 if s.contentType=='NDG_B_SERVICE': 178 s.url=Bobject.URL 179 bdone=1 180 print '4' 181 if not bdone: self.services.append( 182 DIFService('NDG_B_SERVICE',Bobject.URL,'NDG Browse Metadata Service')) 166 183 else: self.binding=None 167 184 print '5' 168 185 if self.debug: 169 186 f=open('difs.log','a') -
TI07-MOLES/trunk/PythonCode/wsgi/DiscoveryGUI.py
r2417 r2422 139 139 obj.setConfig(self.config) 140 140 try: 141 difs.append(DIF(result[1],ndgObj ect=obj))141 difs.append(DIF(result[1],ndgObj=obj)) 142 142 except ValueError,e: 143 errors.append((result[0], e))143 errors.append((result[0],str(e))) 144 144 if results==[]: 145 145 self.html+='<p>No results for "%s"!</p>'%searchString -
TI07-MOLES/trunk/PythonCode/wsgi/ndgDiscovery.config
r2380 r2422 75 75 # needs to be mapped into a specific server ... 76 76 badc.nerc.ac.uk: chinook.badc.rl.ac.uk 77 neodc.nerc.ac.uk: chinook.badc.rl.ac.uk 77 78 bodc.nerc.ac.uk: BODC-dummyHost 78 79 grid.bodc.nerc.ac.uk: BODC-dumyHOST-G -
TI07-MOLES/trunk/PythonCode/wsgi/ndgObject.py
r2380 r2422 6 6 7 7 def __init__(self,uri,config=None): 8 9 ''' Instantiate an ndg URI, and potentially methods for retrieving documents described by this URI. 10 11 If discoveryOriginal is set, then it indicates that the URI provided corresponds to an original 12 URI which can be obtained both from the original database, and via transformation from the 13 intermediate schema (aka mini-moles) database ''' 8 ''' Instantiate an ndg URI, and potentially methods for retrieving documents described by this URI 9 if a config file is available. Three default views should be available: 10 (1) a rendered html version 11 (2) a downloadable xml representation, and 12 (3) a printable xml version. 13 Real services should also be available, and at some point of course the services should be looked up 14 at a service registry, but that's not yet available. ''' 14 15 15 bits=uri.split(':') 16 self.gettable=-1 # The specific record is not known to be gettable via any service 17 # other values of gettable allowed are 18 # 0: browseable, 1: discoverable 19 20 # handle all the known ways of doing an NDG URI ... 21 bits=uri.split(':') 16 22 bits2=uri.split('__') 17 23 ok=1 … … 37 43 else: ok=0 38 44 if not ok: 45 # after all that, we don't think it's an NDG URI ... 39 46 raise ValueError,'URI [%s] is not a valid NDG style URI'%uri 40 47 else: 48 # yes, it is an NDG URI ... 41 49 self.repository,self.schema,self.localID=repository,schema,localID 42 50 self.setConfig(config) … … 45 53 ''' Set up the configuration for retrieving this document ''' 46 54 if config is None: 47 self.gettable=-148 55 self.discoveryURL,self.baseURL,self.xmlURL,self.printableURL=None,None,None,None 49 56 else: 50 57 self.config=config 51 # this NDG object may itself be a discovery record, which makes life easy, but58 # This NDG object may itself be a discovery record, which makes life easy, but 52 59 # it might not be, in which case we have to build up all the possible views upon it. 53 60 discoveryBASE='%s&uri=%s__%s__%s'%( 54 61 self.config.get('DISCOVERY','default'),self.repository,self.schema,self.localID) 55 62 fmt=self.config.get('DISCOVERY','formatDefault','DIF') 63 # We'll build the following even if it can't be used (as would be the case for 64 # a non data entity B record or an A record) because it's a useful template. 56 65 self.discoveryURL=discoveryBASE+'&format=%s&type=html'%fmt 57 66 # If this record is itself a discovery record, then we don't have much more to do … … 62 71 self.URL=self.discoveryURL 63 72 elif self.schema in ['NDG-B0','NDG-B1']: 64 # one day we'll use a service binding to get this65 # this is a mapping from the ndg repository id to an actual repository id66 # understood by the ndg exist interface73 # One day we'll use a service binding to get this 74 # This is a mapping from the ndg repository id to an actual repository id 75 # understood by the ndg exist interface 67 76 repository=self.config.get('NDG_B_SERVICE',self.repository,'Unknown-B-Repository') 68 77 url=self.discoveryURL.replace('ndg',repository) … … 70 79 self.xmlURL=self.URL.replace('html','xml') 71 80 self.printableURL=self.URL.replace('html','print') 72 self.gettable=081 if repository!='Unknown-B-Repository': self.gettable=0 73 82 else: 74 83 #currently we don't know how to get this one 75 self.gettable=-176 84 self.URL='unknown' 77 85 self.discoveryURL,self.baseURL,self.xmlURL,self.printableURL=None,None,None,None 86 87 #now, we'll build a stub-B url as well, in cae that comes in handy 78 88 if self.gettable<>-1: 79 89 if self.schema<>'NDG-B1': -
TI07-MOLES/trunk/PythonCode/wsgi/ndgRetrieve.py
r2386 r2422 41 41 self.renderer=renderEntity(self.config) 42 42 43 def get(self,xml,format,otype='html',ndgObj ect=None):43 def get(self,xml,format,otype='html',ndgObj=None): 44 44 if otype=='html': 45 45 if format=='DIF': 46 r=DIF(xml,ndgObj ect=ndgObject)46 r=DIF(xml,ndgObj=ndgObj) 47 47 elif format=='NDG-B1': 48 48 r=stubB(xml,self.config) … … 159 159 if outputType!='xml': 160 160 if debug: 161 r=self.shower.get(r,format,otype=outputType,ndgObj ect=self.uri)161 r=self.shower.get(r,format,otype=outputType,ndgObj=self.uri) 162 162 else: 163 163 try: 164 r=self.shower.get(r,format,otype=outputType,ndgObj ect=self.uri)164 r=self.shower.get(r,format,otype=outputType,ndgObj=self.uri) 165 165 except Exception,e: 166 166 r='<p> Unable to show document, reason was [%s]<p>'%e -
TI07-MOLES/trunk/PythonCode/wsgi/renderService.py
r2330 r2422 55 55 obj=ndgObject(testURI) 56 56 obj.setConfig(con) 57 d=DIF(r,ndgObj ect=obj)57 d=DIF(r,ndgObj=obj) 58 58 for s in d.services: 59 59 h=renderService(con) -
TI07-MOLES/trunk/PythonCode/wsgi/stubB.py
r2392 r2422 158 158 self.config=config 159 159 self.citation='' 160 self.personnel=[] # for DIF compatiability for the moment. 160 161 161 162 try:
Note: See TracChangeset
for help on using the changeset viewer.