Changeset 2502


Ignore:
Timestamp:
22/05/07 14:37:01 (12 years ago)
Author:
spascoe
Message:

Some bug fixes to ows_common. OwsController?._load_capabilities implements
discovery of capabilities from a controller definition.

Location:
TI05-delivery/ows_framework/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/contents.py

    r2475 r2502  
    1010 
    1111from ows_common.data_identification import Description 
    12 from ows_common.is19115_subset import (Code, Metadata, BoundingBox, WGS84BoundingBox, 
    13                                 Keywords) 
     12from ows_common.iso19115_subset import Code, Keywords 
     13from ows_common.common import Metadata, BoundingBox, WGS84BoundingBox 
    1414 
    1515class Contents(object): 
     
    4545        self.metadata = metadata 
    4646        self.boundingBoxes = boundingBoxes 
    47         self wsg84BoundingBoxes = wsg84BoundingBoxes 
     47        self.wsg84BoundingBoxes = wsg84BoundingBoxes 
    4848 
    4949         
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/data_identification.py

    r2475 r2502  
    99""" 
    1010 
    11 from ows_common.is19115_subset import LanguageString, Keywords 
     11from ows_common.iso19115_subset import LanguageString, Keywords 
    1212from ows_common.common import Metadata, BoundingBox 
    1313 
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/decorators.py

    r2501 r2502  
    2323    return Domain(defaultValue=value, possibleValues=pv, 
    2424                  meaning=meaning, dataType=dataType, valuesUnit=valuesUnit) 
     25 
     26def operation(method): 
     27    """ 
     28    A decorator which tags a method as a OWS operation. 
     29 
     30    """ 
     31    method._ows_name = method.__name__ 
     32 
     33    return method 
    2534 
    2635def parameter(name, value=None, possibleValues=None, 
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/get_capabilities.py

    r2475 r2502  
    2222 
    2323    """ 
    24     def __init__(self, serviceIdentification=None, serviceProvider=None 
     24    def __init__(self, serviceIdentification=None, serviceProvider=None, 
    2525                 operationsMetadata=None, contents=None): 
    2626        self.serviceIdentification = serviceIdentification 
    2727        self.serviceProvider = serviceProvider 
    28         self.serviceMetadata = serviceMetadata 
     28        self.operationsMetadata = operationsMetadata 
    2929        self.contents = contents 
    3030         
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/operations_metadata.py

    r2475 r2502  
    1818 
    1919from ows_common.domain import Domain 
    20 from ows_common.is19115_subset import OnlineResource 
     20from ows_common.iso19115_subset import OnlineResource 
    2121 
    2222class OperationsMetadata(object): 
     
    2727    @type operationDict: dictionary mapping names to Operation objects 
    2828    @ivar constraints 
    29     @type constraints: iterable of Domain objects 
     29    @type constraints: dictionary of Domain objects 
    3030    @ivar parameters 
    31     @ivar parameters: iterable of Domain objects 
     31    @ivar parameters: dictionary of Domain objects 
    3232 
    3333    """ 
    34     def __init__(self, operationDict, constraints=[], parameters=[]): 
     34    def __init__(self, operationDict, constraints={}, parameters={}): 
    3535        self.operationDict = operationDict 
    3636        self.constraints = constraints 
     
    5454    @ivar post 
    5555    @type post: None or RequestMethod 
     56    @ivar constraints 
     57    @type constraints: dictionary of Domain objects 
     58    @ivar parameters 
     59    @type parameters: dictionary of Domain objects 
    5660 
    5761    """ 
    58     def __init__(self, get=None, post=None): 
     62    def __init__(self, get=None, post=None, constraints={}, parameters={}): 
    5963        self.get = get 
    6064        self.post = post 
     65        self.constraints = constraints 
     66        self.parameters = parameters 
    6167 
    6268class RequestMethod(OnlineResource): 
    6369    """ 
    6470    @ivar constraints 
    65     @type constraints: Iterable of Domain objects 
     71    @type constraints: dictionary of Domain objects 
    6672 
    6773    """ 
    68     def __init__(self, constraints=[], **kwargs): 
     74    def __init__(self, constraints={}, **kwargs): 
    6975        super(RequestMethod, self).__init__(**kwargs) 
    7076 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wms.py

    r2501 r2502  
    2222        } 
    2323 
    24     _ows_constraints = { 
     24    #_ows_constraints = { 
    2525        # MaximumLayerLevels 
    2626        # MaximumWidth 
    2727        # MaximumWidth 
    28         } 
     28    #    } 
    2929     
     30    @operation 
    3031    @parameter('Format', possibleValues=['text/xml']) 
    3132    def GetCapabilities(self, file, service, version=None): 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/base.py

    r2494 r2502  
    88import ows_server.lib.helpers as h 
    99 
    10 from ows_common.exception_report import OwsError 
     10from ows_common import exceptions as OWS_E 
     11from ows_common.operations_metadata import OperationsMetadata, Operation 
     12from ows_common.get_capabilities import ServiceMetadata 
    1113 
    1214class BaseController(WSGIController): 
     
    1618        # the action or route vars here 
    1719        return WSGIController.__call__(self, environ, start_response) 
    18  
     20     
    1921class OwsController(BaseController): 
    2022    def __call__(self, environ, start_response): 
     23 
     24        # Ensure the capabilities document is loaded 
     25        self._load_capabilities() 
    2126 
    2227        # All OWS parameter names are case insensitive. 
     
    3944            action = self.ows_params['request'] 
    4045        except KeyError: 
    41             raise OwsError('MissingParameterValue', 'request parameter not specified', 'request') 
     46            raise OWS_E.MissingParameterValue('REQUEST parameter not specified', 'REQUEST') 
    4247 
    4348        # Check action is a method in self 
    4449        if not getattr(self, action): 
    45             raise OwsError('InvalidParameterValue', 'request=%s not supported' % action, 'request') 
     50            raise OWS_E.InvalidParameterValue('request=%s not supported' % action, 'REQUEST') 
    4651 
    4752        # override routes action with request 
     
    5055 
    5156    def _get_method_args(self): 
    52         """Extends Controller._get_method_args to retrieve arguments from the query string. 
     57        """Extends Controller._get_method_args to retrieve arguments 
     58        from the query string. 
    5359 
    5460        See the docstring for Controller._get_method_args for details. 
     
    6268        return kargs 
    6369 
     70    def _load_capabilities(self, ows_endpoint): 
     71        """ 
     72        creates an ows_common.get_capabilities.ServiceMetadata object 
     73        by consulting the paste configuration and annotations in the 
     74        controller definition.  The endpoint must be supplied to allow 
     75        a controller to serve multiple ows endpoints. 
     76 
     77        @param ows_endpoint: The URI of the OWS endpoint being served 
     78            by this controller. 
     79 
     80        """ 
     81        if hasattr(self, '_ows_service_metadata'): 
     82            return 
     83 
     84        parameters = getattr(self, '_ows_parameters', {}) 
     85        constraints = getattr(self, '_ows_constraints', {}) 
     86 
     87        od = {} 
     88        for attr in dir(self): 
     89            op = getattr(self, attr) 
     90            if hasattr(op, '_ows_name'): 
     91                p = getattr(op, '_ows_parameters', {}) 
     92                c = getattr(op, '_ows_constraints', {}) 
     93                od[op._ows_name] = Operation(get=ows_endpoint, 
     94                                                    post=None, 
     95                                                    parameters=p, 
     96                                                    constraints=c) 
     97         
     98        om = OperationsMetadata(od, constraints, parameters) 
     99        return ServiceMetadata(operationsMetadata=om) 
     100 
    64101# Include the '_' function in the public names 
    65102__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \ 
Note: See TracChangeset for help on using the changeset viewer.