Changeset 3481 for TI05-delivery/ows_framework
- Timestamp:
- 20/02/08 17:01:58 (13 years ago)
- Location:
- TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/builder.py
r3453 r3481 61 61 abstract = siConfig.get('abstract') 62 62 63 keywords = siConfig.get('keywords', []).split()63 keywords = siConfig.get('keywords', '').split() 64 64 65 65 return ServiceIdentification(serviceType=type, -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/operations_metadata.py
r2711 r3481 60 60 @ivar name 61 61 @type name: None or str 62 63 @todo: Do we need name now? It duplicates OperationsMetadata.operationDict keys. 64 62 65 """ 63 66 def __init__(self, get=None, post=None, constraints={}, parameters={}, name=None): -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/ows_controller.py
r3450 r3481 8 8 9 9 10 from pylons import request, response, config 10 from pylons import request, response, config, c 11 11 from pylons.controllers import WSGIController 12 12 from pylons.templating import render 13 from webhelpers import url_for 13 14 14 15 from ows_common import exceptions as OWS_E 15 16 from ows_common.util import negotiate_version, check_updatesequence 17 from ows_common.builder import loadConfigFile 18 from ows_common import helpers 19 from ows_common.operations_metadata import * 16 20 17 21 from genshi.template import TemplateLoader 22 from pkg_resources import resource_filename 18 23 19 24 try: … … 27 32 # Instantiate Genshi template loader 28 33 genshiLoader = TemplateLoader( 29 resource_filename('ows_common.pylons', 'templates') 30 auto_reload=True 34 resource_filename('ows_common.pylons', 'templates'), 35 auto_reload=True, 31 36 ) 32 37 … … 43 48 Initially these comes from the query string but could come from 44 49 a HTTP POST in future. 45 @cvar owsOperations: A dictionary of operation configuration options.50 @cvar owsOperations: A list of operation names 46 51 47 52 """ 48 53 49 owsOperations = {}54 owsOperations = [] 50 55 51 56 def __call__(self, environ, start_response): … … 83 88 84 89 # Check action is a method in self and is defined as an OWS operation 85 try: 86 self.opConfig = self.owsOperations[action] 87 except AttributeError: 90 if action not in self.owsOperations: 88 91 raise OWS_E.InvalidParameterValue('request=%s not supported' % action, 89 92 'REQUEST') … … 112 115 Adds basic GetCapabilities response to OwsControllerBase. 113 116 114 @ ivar service: If None does not enforce the SERVICE parameter. Otherwise117 @cvar service: If None does not enforce the SERVICE parameter. Otherwise 115 118 raises exception if SERVICE is not correct on GetCapabilities request. 116 @ivar validCapabilitiesFormats: Sequence of supported Capabilities117 mime-types.118 119 @cvar validVersions: A list of supported version numbers. Automatic 119 120 version negotiation is performed according to this attribute. … … 124 125 """ 125 126 127 owsOperations = ['GetCapabilities'] 128 126 129 # Override these attributes to control how OwsController responds to 127 130 # GetCapabilities … … 129 132 validVersions = NotImplemented 130 133 131 owsOperations = dict( 132 GetCapabilities = dict(formats=('text/xml',)) 133 ) 134 134 # To enable cache control set this instance attribute in self.__before__(). 135 135 updateSequence = None 136 137 136 138 137 def GetCapabilities(self): … … 142 141 version = self.getOwsParam('version', default=None) 143 142 format = self.getOwsParam('format', default='text/xml') 144 update sequence = self.getOwsParam('updatesequence', default=None)143 updateSequence = self.getOwsParam('updatesequence', default=None) 145 144 146 145 # Check update sequence … … 148 147 149 148 # Do version negotiation 150 version = negotiate_version( version, self.validVersions)149 version = negotiate_version(self.validVersions, version) 151 150 152 151 # Get information required for the capabilities document 153 self._loadCapabilities 152 self._initCapabilities() 153 self._loadCapabilities() 154 154 155 155 # Render the capabilities document … … 157 157 return self._renderCapabilities(version, format) 158 158 159 def _initCapabilities(self): 160 """ 161 Initialise the capabilities object c.capabilities. 162 163 By default the server-wide configuration file is loaded and 164 used to populate some standard metadata. The GetCapabilites 165 operation is added. 166 167 """ 168 # Load the basic ServiceMetadata from a config file 169 configFile = config.get('ows_server.capabilities_config') 170 c.capabilities = loadConfigFile(configFile) 171 172 getCap = helpers.operation(url_for(), formats=['text/xml']) 173 om = OperationsMetadata(operationDict=dict(GetCapabilities=getCap)) 174 c.capabilities.operationsMetadata = om 175 176 def _loadCapabilities(self): 177 """ 178 Override in subclasses to populate c.capabilities with 179 operation and contents metadata. 180 181 """ 182 pass 159 183 160 184 def _renderCapabilities(self, version, format): 161 185 """ 162 186 Override in subclases to render the capabilities document. 163 The response mime-type will already have been set. 187 The response mime-type will already have been set. Raise an 188 OWS exception if the format is not supported. 164 189 165 190 @param version: the version as a string -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_capabilities_1_1_1.xml
r3458 r3481 6 6 7 7 from genshi.builder import tag, Element 8 from ows_common.pylons.genshi_util import RenameElementFilter 9 from genshi import QName 8 10 9 11 ?> … … 19 21 --> 20 22 21 <Operation py:def="_opContent(op)" py:strip="True">23 <Operation py:def="_opContent(op)"> 22 24 <Format py:for="f in op.parameters['Format'].possibleValues.allowedValues" py:content="f"/> 23 25 <DCPType><HTTP> 24 <Get> OnlineResource xlink:href="${h.url_for()}?"</Get>26 <Get><OnlineResource xlink:href="${op.get.href}"/></Get> 25 27 </HTTP></DCPType> 26 28 </Operation> 27 29 <?python 28 30 29 def markupOperation(op ):31 def markupOperation(opName, op): 30 32 """Render an OWS operation description for the Capabilities section. 31 33 """ 32 return Element(op.name)(_opContent(op).generate()) 34 35 return RenameElementFilter(QName(opName))(_opContent(op)) 33 36 34 37 ?> … … 65 68 66 69 67 <Service py:with="sm=c. service_metadata; si=c.service_metadata.serviceIdentification">70 <Service py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification"> 68 71 <Name>WMS</Name> 69 72 <Title py:content="si.titles[0]"/> … … 86 89 <ContactAddress py:if="cn.address is not None"> 87 90 <AddressType>postal</AddressType> 88 <Address py:for="d in cn.address.deliveryPoints" py:content="d"/> 91 <Address> 92 <py:for each="d in cn.address.deliveryPoints">${d}</py:for> 93 </Address> 89 94 <City py:content="cn.address.city"/> 90 95 <StateOrProvince py:content="cn.address.administrativeArea"/> … … 106 111 107 112 <!--! These fields are represented in ows_common as service constraints --> 108 <Capability py:with="sm=c. service_metadata; om=sm.operationsMetadata">113 <Capability py:with="sm=c.capabilities; om=sm.operationsMetadata"> 109 114 <py:if test="om is not None"> 110 115 <py:for each="opName, op in om.operationDict.items()"> -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/util.py
r3450 r3481 4 4 # http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 5 5 """ 6 Utilities for constructing ows_common objects6 Utilities for OWS protocol processing. 7 7 8 8 @author: Stephen Pascoe 9 9 """ 10 10 11 from ows_common.domain import Domain, PossibleValues12 11 from ows_common import exceptions as OWS_E 13 14 def make_domain(value=None, possibleValues=None, **kwargs):15 """16 Construct a domain object.17 18 @param value: The defaultValue of the domain19 @param possibleValues: Either a list of possible values,20 a PossibleValues object or None to represent any value21 @param kwargs: all other arguments passed to the Domain constructor.22 """23 if possibleValues is None:24 pv = PossibleValues.fromAnyValue()25 elif isinstance(possibleValues, PossibleValues):26 pv = possibleValues27 else:28 pv = PossibleValues.fromAllowedValues(possibleValues)29 30 return Domain(defaultValue=value, possibleValues=pv, **kwargs)31 32 33 12 34 13 … … 80 59 raise OWS_E.InvalidUpdateSequence 81 60 82 61 83 62 84 63 #-----------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.