Ignore:
Timestamp:
20/11/08 15:36:44 (11 years ago)
Author:
cbyrom
Message:

Strip out code not relevant to MILK - mainly WCS and WMS stuff - also including the CSML server code + trackback code
Also tidy up structure of 'public' dir - setting up new 'style' dir and
centralising icons in icons dir + remove all unused icons, javascript and stylesheets.
Also strip out testcase code and populate new test directory structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/lib/base.py

    r4066 r4469  
    1414from pylons.i18n import N_, _, ungettext 
    1515from paste.request import construct_url 
    16 import ows_server.models as model 
    17 import ows_server.lib.helpers as h 
    18 from ows_common import exceptions as OWS_E 
    19 from ows_common.operations_metadata import OperationsMetadata, Operation, RequestMethod 
    20 from ows_common.get_capabilities import ServiceMetadata 
    21 import ows_common.xml 
     16import milk_server.models as model 
     17import milk_server.lib.helpers as h 
    2218 
    2319# NDG Security import enables Single Sign On capability but note this is not 
     
    4541 
    4642# Configure 
    47 EXCEPTION_TYPE = request.environ['ndgConfig'].get('OWS_SERVER', 'exception_type', 'ogc').lower() 
     43EXCEPTION_TYPE = request.environ['ndgConfig'].get('MILK_SERVER', 'exception_type', 'ogc').lower() 
    4844 
    4945class BaseController(_BaseController): 
     
    6965         
    7066        return _BaseController.__call__(self, environ, start_response) 
    71      
    72 class OwsController(BaseController): 
    73     def __call__(self, environ, start_response): 
    74  
    75         # All OWS parameter names are case insensitive. 
    76         req = request._current_obj() 
    77         self.ows_params = {} 
    78         for k in req.params: 
    79             self.ows_params[k.lower()] = req.params[k]         
    80  
    81         # If the EXCEPTION_TYPE is 'pylons' let Pylons catch any exceptions. 
    82         # Otherwise send an OGC exception report for any OWS_E.OwsError 
    83         if 'pylons' in EXCEPTION_TYPE: 
    84             self._fixOwsAction(environ) 
    85             return super(OwsController, self).__call__(environ, start_response) 
    86         else: 
    87             try: 
    88                 self._fixOwsAction(environ) 
    89                 return super(OwsController, self).__call__(environ, start_response) 
    90             except OWS_E.OwsError, e: 
    91                 logger.exception(e) 
    92                 start_response('400 Bad Request',[('Content-type','text/xml')]) 
    93 #                response.headers['content-type'] = 'text/xml' 
    94                 return render('exception_report', report=e.report, format='xml') 
    95  
    96  
    97     def _fixOwsAction(self, environ): 
    98         # Override the Routes action from the request query parameter 
    99         try: 
    100             action = self.ows_params['request'] 
    101         except KeyError: 
    102             raise OWS_E.MissingParameterValue('REQUEST parameter not specified', 'REQUEST') 
    103  
    104         # Check action is a method in self 
    105         if not getattr(self, action): 
    106             raise OWS_E.InvalidParameterValue('request=%s not supported' % action, 'REQUEST') 
    107  
    108         # override routes action with request 
    109         environ['pylons.routes_dict']['action'] = action 
    110         del self.ows_params['request'] 
    111  
    112     def _loadCapabilities(self): 
    113         """ 
    114         creates an ows_common.get_capabilities.ServiceMetadata object 
    115         by consulting the paste configuration and annotations in the 
    116         controller definition. 
    117  
    118         """ 
    119         # Deduce ows_endpoint from routes 
    120         ows_endpoint = h.url_for(controller=request.environ['pylons.routes_dict']['controller']) 
    121          
    122         #Deduce base_url from config 
    123         base_url =request.environ['ndgConfig'].get('DEFAULT','server') 
    124  
    125          
    126         # Get the server-level configuration data from an XML file 
    127         config = request.environ['paste.config'] 
    128         sm_tree = ET.parse(config['ows_common_config']) 
    129         sm = ows_common.xml.service_metadata(sm_tree.getroot()) 
    130          
    131         # Extract service-level parameters and constraint 
    132         parameters = getattr(self, '_ows_parameters', {}) 
    133         constraints = getattr(self, '_ows_constraints', {}) 
    134         versions = getattr(self, '_ows_versions', []) 
    135          
    136         # Extract operation-level parameters and constraints 
    137         od = {} 
    138         for attr in dir(self): 
    139             op = getattr(self, attr) 
    140             if hasattr(op, '_ows_name'): 
    141                 p = getattr(op, '_ows_parameters', {}) 
    142                 c = getattr(op, '_ows_constraints', {}) 
    143                 od[op._ows_name] = Operation(get=RequestMethod(href=base_url+ows_endpoint), 
    144                                              post=None, 
    145                                              parameters=p, 
    146                                              constraints=c, 
    147                                              name=op._ows_name) 
    148          
    149         sm.operationsMetadata = OperationsMetadata(od, constraints, parameters) 
    150         sm.serviceIdentification.serviceTypeVersions = versions 
    151         return sm 
    152  
    153     def _renderCapabilities(self, template='ows/get_capabilities'): 
    154         """ 
    155         The standard way of returning a Capabilities document. 
    156  
    157         Each subclass should implement self._load_capabilities() and call 
    158         this method to return a response object. 
    159  
    160         """ 
    161         c.service_metadata = self._loadCapabilities()         
    162         response.headers['content-type'] = 'text/xml' 
    163         return render(template, format='xml') 
    16467 
    16568 
Note: See TracChangeset for help on using the changeset viewer.