Ignore:
Timestamp:
20/04/07 08:12:11 (13 years ago)
Author:
lawrence
Message:

Code to support late binding to Browse service

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/ndgObject.py

    r2380 r2422  
    66     
    77    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. ''' 
    1415         
    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(':') 
    1622        bits2=uri.split('__') 
    1723        ok=1 
     
    3743            else: ok=0 
    3844        if not ok: 
     45            # after all that, we don't think it's an NDG URI ... 
    3946            raise ValueError,'URI [%s] is not a valid NDG style URI'%uri 
    4047        else: 
     48            # yes, it is an NDG URI ... 
    4149            self.repository,self.schema,self.localID=repository,schema,localID 
    4250        self.setConfig(config) 
     
    4553        ''' Set up the configuration for retrieving this document ''' 
    4654        if config is None: 
    47             self.gettable=-1 
    4855            self.discoveryURL,self.baseURL,self.xmlURL,self.printableURL=None,None,None,None 
    4956        else: 
    5057            self.config=config 
    51             # this NDG object may itself be a discovery record, which makes life easy, but 
     58            # This NDG object may itself be a discovery record, which makes life easy, but 
    5259            # it might not be, in which case we have to build up all the possible views upon it. 
    5360            discoveryBASE='%s&uri=%s__%s__%s'%( 
    5461                self.config.get('DISCOVERY','default'),self.repository,self.schema,self.localID) 
    5562            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. 
    5665            self.discoveryURL=discoveryBASE+'&format=%s&type=html'%fmt 
    5766            # If this record is itself a discovery record, then we don't have much more to do 
     
    6271                self.URL=self.discoveryURL 
    6372            elif self.schema in ['NDG-B0','NDG-B1']: 
    64                 #one day we'll use a service binding to get this 
    65                 #this is a mapping from the ndg repository id to an actual repository id 
    66                 #understood by the ndg exist interface 
     73                # 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 
    6776                repository=self.config.get('NDG_B_SERVICE',self.repository,'Unknown-B-Repository') 
    6877                url=self.discoveryURL.replace('ndg',repository) 
     
    7079                self.xmlURL=self.URL.replace('html','xml') 
    7180                self.printableURL=self.URL.replace('html','print') 
    72                 self.gettable=0 
     81                if repository!='Unknown-B-Repository': self.gettable=0 
    7382            else: 
    7483                #currently we don't know how to get this one 
    75                 self.gettable=-1 
    7684                self.URL='unknown' 
    7785                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  
    7888        if self.gettable<>-1: 
    7989            if self.schema<>'NDG-B1': 
Note: See TracChangeset for help on using the changeset viewer.