wiki:OwsFramework/Decorators

The ows_common.pylons.decorators module provides a set of decorators for setting attributes of the OWS controller protocol. These are added to the beginning of operation definitions e.g.:

class WmsController(OwsController):

    # ...

    @ows_operation
    @ows_parameter('Format', possibleValues=['text/xml'])
    @ows_parameter('Service', possibleValues=['WMS'], required=True)
    @ows_parameter('Version', possibleValues=['1.3.0'])
    def GetCapabilities(self, file, service=None, version=None):
        # ...
@ows_operation
Should be the top-most decorator. It wraps the method in a function that performs request handling and type checking on the operation's arguments.
@ows_parameter
Add one of these for each operation parameter. This instructs the framework to perform several tasks.
  1. Add the parameter (from request.params) to the list of arguments send to the operation method.
  2. Populate ows_common objects to describe this parameter in the GetCapabilities? document.
  3. Do type-checking on the parameter's value during invocation. The possibleValues argument allows you to define a set of possible values, the require argument can declare an argument required and the validator argument allows you to provide a validation function.
@ows_constraint
OWS common 1.3.0 allows you to define constraints on operations. This decorator will populate the necessary ows_common objects for describing the constraint in the GetCapabilities? document.