Changes between Version 7 and Version 8 of OwsFramework


Ignore:
Timestamp:
29/05/07 10:03:15 (12 years ago)
Author:
spascoe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OwsFramework

    v7 v8  
    88 - OwsFramework/UsingPylons.  How the framework is built on the [http://pylonshq.com Pylons] web framework. 
    99 
    10 = Implementing an OWS framework on top of pylons = 
    11  
    12 == Introduction to Pylons == 
    13  
    14 See the [http://pylonshq.com Pylons home page] for information on Pylons.  Pylons is very much inspired by Ruby on Rails. 
    15  
    16 Pylons is a good framework for encouraging 
    17 [http://en.wikipedia.org/wiki/Separation_of_concerns separation of concerns] in the 
    18 [http://en.wikipedia.org/wiki/Model-view-controller#MVC_frameworks_in_Python Model-View-Controller] style.  Pylons provides base classes for constructing Controllers, it has support for pluggable templating languages for constructing HTML/XML views and plays well with a veriety of model layers (e.g. SQLAlchemy or SQLObject). 
    19  
    20 It is a lightweight framework that builds heavily on [http://pythonpaste.org Paste] and therefore [http://www.python.org/dev/peps/pep-0333/ WSGI].  One nice feature of Pylons is that you can always access the WSGI layer of your application if need be.   
    21  
    22  - You can get at the {{{environ}}} dictionary. 
    23  - Pylons Controllers are WSGI applications. 
    24  - You can embed WSGI applications in Controllers. 
    25  - You're entire application is a WSGI application, configured with PasteDeploy. 
    26  
    27 This flexibility is important because not all Pylons features are a perfect fit for implementing OWS specifications.  For instance [http://routes.groovie.org/ Routes] does not provide a mechanism for 
    28 dispatching according to query string parameters.  For this we will need to extend Pylons' {{{WSGIController}}} class (see below). 
    29  
    30 == Initial UML overview of constructing a service == 
    31  
    32 [[Image(Logical Model.PNG, width=100%)]] 
    33  
    34 == Possible URL scheme == 
    35  
    36 {{{http://<service-base>/<data-granule-path>/wms}}}: A WMS service for a data granule. 
    37  
    38 {{{http://<service-base>/<data-granule-path>/wps}}}: A WPS exposing affordances on the data granule. 
    39  
    40 {{{http://<service-base>/<data-granule-path>/<custom-action>}}}: Any required CSML-API functionality that can't easily be encapsulated in an OWS. 
    41  
    42 This might translate into Routes calls like: 
    43  
    44 {{{ 
    45 #!python 
    46  
    47 m.connect(':dg_path/wms', controller='wms') 
    48 m.connect(':dg_path/wps', controller='wps') 
    49 m.connect(':dg_path/:action', controller='customActions') 
    50  
    51 }}} 
    52   
    53  
    54  
    55 == Sample pseudo-code == 
    56  
    57 Using the OWS Framework developers should be able to construct an OWS Service by subclassing OWSController something like this: 
    58  
    59 {{{ 
    60 #!python 
    61  
    62 from myservice.lib.base import * 
    63 from ows_framework import OWSController 
    64 from ows_csml import csmlStore 
    65  
    66 class WMSController(OWSController): 
    67     """Controller serving the OGC Web Map Service. 
    68  
    69     This is an example of how a controller might look. 
    70  
    71     """ 
    72     def GetCapabilities(self, dg_path): 
    73         """GetCapabilities Operation. 
    74  
    75         OWSController automatically dispatches requests to the method 
    76         with the same name as the REQUEST parameter.  The dg_path parameter 
    77         is available due to it's occurance in the Routes configuration. 
    78  
    79         """ 
    80  
    81         # Get the CSML-API dataset object according to the dg_path argument. 
    82         # Some sort of CSML repository object is envisaged. 
    83         dataset = csmlStore.getDataset(dg_path) 
    84          
    85         # Populate self.capabilities according to service-specific features. 
    86         self.serviceMetadata.serviceProvider.set(individualName='Bob', 
    87                                              positionName='Developer', 
    88                                              role=someCode) 
    89         self.serviceMetadata.serviceProvider.addOnlineResource(someUrl) 
    90         # ... etc. interface TBD. 
    91  
    92         # Get object(s) modelling the WMS service information using the 
    93         # CSML dataset variable. 
    94         # TBD. 
    95  
    96         # The wms_get_capabilities.kid template extends get_capabilities.kid 
    97         # So Sections such as ServiceMetadata are populated automatically. 
    98         return render_response('/wms_get_capabilities.kid', 
    99                                serviceMetadata=self.serviceMetadata, 
    100                                # more kwargs here ... 
    101                                ) 
    102  
    103     def GetMap(self, layers, styles, crs, bbox, width, height, format 
    104                transparent='FALSE', 
    105                # ... etc.): 
    106         """GetMap Operation. 
    107  
    108         FormEncoded parameters to the request (whether in GET or POST) 
    109         are automatically converted to lower-case arguments of the 
    110         same name.  How we support XML encoding of the request is TBD. 
    111  
    112         """ 
    113  
    114         # ... 
    115  
    116 }}} 
    117          
    118 == OWS framework installation notes == 
    119  
    120 This is evolving as I write the code. [SP] 
    121  
    122  1. Install setuptools 
    123  1. {{{$ easy_install Pylons[kid] TurboKid ElementTree}}} (if python2.4 you need element tree) 
    124