Version 1 (modified by spascoe, 12 years ago) (diff)


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?.

Initial UML overview of constructing a service

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

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

    This is an example of how a controller might look.

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

        OWSController automatically dispatches requests to the method
        with the same name as the REQUEST parameter.

        # Populate self.capabilities according to service-specific features.
        # ... etc. interface TBD.

        # Get object(s) modelling the WMS service information
        # 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.


        # ...