Ignore:
Timestamp:
19/06/07 19:16:56 (12 years ago)
Author:
lawrence
Message:

Moving some of the wsgi stack into the ows stack.
At this point an xml dif retrieve works in ows_common.

Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
18 added
5 edited
52 copied

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/development.ini

    r2588 r2615  
    99smtp_server = localhost 
    1010error_email_from = paste@localhost 
     11configfile = ows_server/config/ndgDiscovery.config 
    1112 
    1213[server:main] 
     
    2324tmp_dir = %(here)s/data/tmp 
    2425ows_common_config = %(here)s/eg_ows_capabilities.xml 
     26 
    2527 
    2628# If you'd like to fine-tune the individual locations of the cache data dirs 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/config/middleware.py

    r2599 r2615  
    1313import ows_server.lib.helpers 
    1414import ows_server.lib.app_globals as app_globals 
     15 
     16from ows_server.config.ndgMiddleware import ndgMiddleware 
    1517 
    1618import logging 
     
    4547    # handling middleware underneath 
    4648 
     49    app = ndgMiddleware(app) 
     50 
    4751    # Configure logging 
     52    
    4853    logging.basicConfig(format='%(thread)s %(name)s %(levelname)s %(message)s') 
    4954     
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/retrieve.py

    r2614 r2615  
     1import cgi,time 
    12from ows_server.lib.base import * 
     3from ows_server.models import ndgObject, DocumentRetrieve, ndgSearch, xmlHandler 
     4from paste.request import parse_querystring 
     5 
     6#from ows_server.models import ndgRetrieve 
     7 
    28class RetrieveController(BaseController): 
    3     ''' Provides the pylons controller for retrieving NDG documents ''' 
    4     def index(self): 
    5         return Response('not yet implemented') 
    6     def view(self): 
    7         return Response ('view not yet implemented') 
     9    ''' Provides the pylons controller for retrieving NDG documents. The simple model 
     10    is now that an attempt to retrieve/uri will parse the uri, read the config file, 
     11    and if the local server name is not the same as the uri server name. ''' 
     12     
     13    def __setup(self,uri): 
     14        ''' Common setup stuff for all the actions on this controller ''' 
     15        try: 
     16            self.uri=ndgObject.ndgObject(uri) 
     17        except ValueError,e: 
     18            return e 
     19        self.cf=request.environ['ndgConfig'] 
     20        self.uri.setConfig(self.cf) 
     21        self.requestor=request.environ['REMOTE_ADDR'] 
     22        return 0 
     23        
     24    def index(self,uri): 
     25        ''' Returns the document unadorned in anyway, i.e. the raw xml''' 
     26        status=self.__setup(uri) 
     27        if status: return Response(status) 
     28        status,xml=self._getit() 
     29        if status: 
     30            return Response(xml) 
     31        else: 
     32            return Response(xml) 
     33         
     34    def view(self,uri): 
     35        status=self.__setup(uri) 
     36        if status: return Response(status) 
     37        status,xml=self.__getit() 
     38        return Response(xml) 
     39        if status: 
     40            inputs=dict(parse_querystring(request.environ)) 
     41            if 'format' in inputs: 
     42                if inputs['format']=='xml': 
     43                    x=xmlHandler.xmlHandler(xml,string=1) 
     44                    xml=x.html 
     45            return Response(xml) 
     46        else: 
     47            return Response(xml) 
     48 
     49    def __getit(self): 
     50         
     51        ''' This is the function which implements the document retrieval itself ''' 
     52         
     53        # note that at the moment we'll be instantiating an xmlrpc connection every 
     54        # time, ideally we'd have a pool of them available via the g object  
     55        # see http://docs.pythonweb.org/display/pylonscookbook/Using+the+DB-API+in+Pylons 
     56         
     57        server=self.cf.get('DEFAULT','server') 
     58        if self.uri.schema=='DIF': 
     59            r=server 
     60            ws=ndgSearch.ndgSearch() 
     61        elif self.uri.schema[0:5]=='NDG-B': 
     62            r=self.cf.get('NDG_B_SERVICE',self.uri.repository) 
     63            if r<> server: 
     64                return 0,'The uri [%s] is not available on [%s]'%(self.uri,server) 
     65            ws=DocumentRetrieve.DocumentRetrieve(r) 
     66        elif self.uri.schema=='CSML': 
     67            return 0,'CSML recovery not yet implemented' 
     68        try: 
     69            target='/db/ndg_B_metadata' 
     70            format=self.uri.schema # for now 
     71             
     72            #do the actual search: 
     73            time1=time.time() 
     74            r=ws.get(self.uri.repository,self.uri.schema,self.uri.localID, 
     75                        format=format,targetCollection=target) 
     76            time2=time.time()-time1 
     77            logString='Document retrieve [%s] for [%s] took [%ss]'%(self.uri,self.requestor,time2) 
     78            if logger: logger.info(logString) 
     79 
     80            # did we get a sensible answer? 
     81            if isinstance(r,int): 
     82               return 0,'<p> There are %s identifiers matching your request! </p>'%r 
     83              
     84        except Exception,e: 
     85            return 0,'<p> Unable to retrieve [%s], reason was [%s]</p>'%(self.uri,cgi.escape(str(e))) 
     86                 
     87        return 1,r 
     88         
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/app_globals.py

    r2476 r2615  
    2626             
    2727        """ 
    28         pass 
     28 
    2929         
    3030    def __del__(self): 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/ndg/Utilities.py

    r2448 r2615  
    2525       self.config=ConfigParser.ConfigParser() 
    2626       if not os.path.exists(configfile):  
    27            raise ValueError("Config file doesn't exist [%s]"%configfile) 
     27            
     28           raise ValueError("Config file [%s] doesn't exist in [%s]"%(configfile,os.getcwd())) 
    2829       self.config.read(configfile) 
    2930       logfile=self.get('logging','debugLog',None) 
Note: See TracChangeset for help on using the changeset viewer.