source: TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/model/operations_metadata.py @ 3553

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/model/operations_metadata.py@3553
Revision 3553, 2.5 KB checked in by spascoe, 12 years ago (diff)

Moved all the model classes into their own sub-module.

Line 
1# Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council).
2# This software may be distributed under the terms of the
3# Q Public License, version 1.0 or later.
4# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
5"""
6Classes modelling the OWS Operations Metadata package v1.1.0.
7
8This module makes several simplifications to the OWS model to make it
9more pythonic and restrict the model to it's common usage.
10
11 1. Each operation can have 0..1 get and post request methods
12 2. DCP's are not modelled.  Only HTTP DCP is supported.
13 3. Operation.name becomes a key in the OperationsMetadata.operationDict
14    attribute.
15
16@author: Stephen Pascoe
17"""
18
19from ows_common.model.iso19115_subset import OnlineResource
20
21class OperationsMetadata(object):
22    """
23    @note: extendedCapabilities could be implemented by subclassing.
24
25    @ivar operationDict
26    @type operationDict: dictionary mapping names to Operation objects
27    @ivar constraints
28    @type constraints: dictionary of Domain objects
29    @ivar parameters
30    @ivar parameters: dictionary of Domain objects
31
32    """
33    def __init__(self, operationDict, constraints={}, parameters={}):
34        self.operationDict = operationDict
35        self.constraints = constraints
36        self.parameters = parameters
37
38    @classmethod
39    def fromOperations(klass, **kwargs):
40        """A convenient factory class method for operations.
41
42        @param kwargs: A mapping of operation name to Operation objects
43
44        """
45        return klass(operationDict=kwargs)
46
47class Operation(object):
48    """
49    @note: This class encompasses Operation, DCP and HTTP classes from OWS.
50   
51    @ivar get
52    @type get: None or RequestMethod
53    @ivar post
54    @type post: None or RequestMethod
55    @ivar constraints
56    @type constraints: dictionary of Domain objects
57    @ivar parameters
58    @type parameters: dictionary of Domain objects
59    @ivar name
60    @type name: None or str
61
62    @todo: Do we need name now?  It duplicates OperationsMetadata.operationDict keys.
63   
64    """
65    def __init__(self, get=None, post=None, constraints={}, parameters={}, name=None):
66        self.get = get
67        self.post = post
68        self.constraints = constraints
69        self.parameters = parameters
70        self.name=name
71
72class RequestMethod(OnlineResource):
73    """
74    @ivar constraints
75    @type constraints: dictionary of Domain objects
76
77    """
78    def __init__(self, constraints={}, **kwargs):
79        super(RequestMethod, self).__init__(**kwargs)
80
81        self.constraints = constraints
82
83   
Note: See TracBrowser for help on using the repository browser.