WARNING: This page documents an old version of CEDA's OWS framework. Please see CowsFramework for the latest developments

OwsFramework / UsingPylons

Implementing an OWS framework on top of pylons

Introduction to Pylons

See the  Pylons home page for information on Pylons. Pylons is very much inspired by Ruby on Rails.

Pylons is a good framework for encouraging  separation of concerns in the  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).

It is a lightweight framework that builds heavily on  Paste and therefore  WSGI. One nice feature of Pylons is that you can always access the WSGI layer of your application if need be.

  • You can get at the environ dictionary.
  • Pylons Controllers are WSGI applications.
  • You can embed WSGI applications in Controllers.
  • You're entire application is a WSGI application, configured with PasteDeploy?.

This flexibility is important because not all Pylons features are a perfect fit for implementing OWS specifications. For instance  Routes does not provide a mechanism for dispatching according to query string parameters. For this we will need to extend Pylons' WSGIController class (see below).

Initial UML overview of constructing a service

Plan of how the OWS framework will look from a Controller's perspective

Possible URL scheme

http://<service-base>/<data-granule-path>/wms: A WMS service for a data granule.

http://<service-base>/<data-granule-path>/wps: A WPS exposing affordances on the data granule.

http://<service-base>/<data-granule-path>/<custom-action>: Any required CSML-API functionality that can't easily be encapsulated in an OWS.

This might translate into Routes calls like:

m.connect(':dg_path/wms', controller='wms')
m.connect(':dg_path/wps', controller='wps')
m.connect(':dg_path/:action', controller='customActions')

Sample pseudo-code

Using the OWS Framework developers should be able to construct an OWS Service by subclassing OWSController something like this:

from myservice.lib.base import *
from ows_framework import OWSController
from ows_csml import csmlStore

class WMSController(OWSController):
    """Controller serving the OGC Web Map Service.

    This is an example of how a controller might look.

    def GetCapabilities(self, dg_path):
        """GetCapabilities Operation.

        OWSController automatically dispatches requests to the method
        with the same name as the REQUEST parameter.  The dg_path parameter
        is available due to it's occurance in the Routes configuration.


        # Get the CSML-API dataset object according to the dg_path argument.
        # Some sort of CSML repository object is envisaged.
        dataset = csmlStore.getDataset(dg_path)
        # Populate self.capabilities according to service-specific features.
        # ... etc. interface TBD.

        # Get object(s) modelling the WMS service information using the
        # CSML dataset variable.
        # TBD.

        # The wms_get_capabilities.kid template extends get_capabilities.kid
        # So Sections such as ServiceMetadata are populated automatically.
        return render_response('/wms_get_capabilities.kid',
                               # more kwargs here ...

    def GetMap(self, layers, styles, crs, bbox, width, height, format
               # ... etc.):
        """GetMap Operation.

        FormEncoded parameters to the request (whether in GET or POST)
        are automatically converted to lower-case arguments of the
        same name.  How we support XML encoding of the request is TBD.


        # ...

OWS framework installation notes

This is evolving as I write the code. [SP]

  1. Install setuptools
  2. $ easy_install Pylons[kid] TurboKid ElementTree (if python2.4 you need element tree)


  • Logical Model.PNG Download (17.5 KB) - added by spascoe 15 years ago. Plan of how the OWS framework will look from a Controller's perspective