Ignore:
Timestamp:
20/02/08 17:01:58 (12 years ago)
Author:
spascoe
Message:

WMS 1.1.1 capabilities improved

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  
    6161        abstract = siConfig.get('abstract') 
    6262 
    63         keywords = siConfig.get('keywords', []).split() 
     63        keywords = siConfig.get('keywords', '').split() 
    6464 
    6565        return ServiceIdentification(serviceType=type, 
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/operations_metadata.py

    r2711 r3481  
    6060    @ivar name 
    6161    @type name: None or str 
     62 
     63    @todo: Do we need name now?  It duplicates OperationsMetadata.operationDict keys. 
     64     
    6265    """ 
    6366    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  
    88 
    99 
    10 from pylons import request, response, config 
     10from pylons import request, response, config, c 
    1111from pylons.controllers import WSGIController 
    1212from pylons.templating import render 
     13from webhelpers import url_for 
    1314 
    1415from ows_common import exceptions as OWS_E 
    1516from ows_common.util import negotiate_version, check_updatesequence 
     17from ows_common.builder import loadConfigFile 
     18from ows_common import helpers 
     19from ows_common.operations_metadata import * 
    1620 
    1721from genshi.template import TemplateLoader 
     22from pkg_resources import resource_filename 
    1823 
    1924try: 
     
    2732# Instantiate Genshi template loader 
    2833genshiLoader = TemplateLoader( 
    29     resource_filename('ows_common.pylons', 'templates') 
    30     auto_reload=True 
     34    resource_filename('ows_common.pylons', 'templates'), 
     35    auto_reload=True, 
    3136    ) 
    3237 
     
    4348        Initially these comes from the query string but could come from 
    4449        a HTTP POST in future. 
    45     @cvar owsOperations: A dictionary of operation configuration options. 
     50    @cvar owsOperations: A list of operation names 
    4651    
    4752    """ 
    4853 
    49     owsOperations = {} 
     54    owsOperations = [] 
    5055     
    5156    def __call__(self, environ, start_response): 
     
    8388 
    8489        # 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: 
    8891            raise OWS_E.InvalidParameterValue('request=%s not supported' % action, 
    8992                                              'REQUEST') 
     
    112115    Adds basic GetCapabilities response to OwsControllerBase. 
    113116 
    114     @ivar service: If None does not enforce the SERVICE parameter.  Otherwise 
     117    @cvar service: If None does not enforce the SERVICE parameter.  Otherwise 
    115118        raises exception if SERVICE is not correct on GetCapabilities request. 
    116     @ivar validCapabilitiesFormats: Sequence of supported Capabilities 
    117         mime-types. 
    118119    @cvar validVersions: A list of supported version numbers.  Automatic 
    119120        version negotiation is performed according to this attribute. 
     
    124125    """ 
    125126 
     127    owsOperations = ['GetCapabilities'] 
     128 
    126129    # Override these attributes to control how OwsController responds to 
    127130    # GetCapabilities 
     
    129132    validVersions = NotImplemented 
    130133 
    131     owsOperations = dict( 
    132         GetCapabilities = dict(formats=('text/xml',)) 
    133         ) 
    134  
     134    # To enable cache control set this instance attribute in self.__before__(). 
    135135    updateSequence = None 
    136  
    137136     
    138137    def GetCapabilities(self): 
     
    142141        version = self.getOwsParam('version', default=None) 
    143142        format = self.getOwsParam('format', default='text/xml') 
    144         updatesequence = self.getOwsParam('updatesequence', default=None) 
     143        updateSequence = self.getOwsParam('updatesequence', default=None) 
    145144 
    146145        # Check update sequence 
     
    148147 
    149148        # Do version negotiation 
    150         version = negotiate_version(version, self.validVersions) 
     149        version = negotiate_version(self.validVersions, version) 
    151150 
    152151        # Get information required for the capabilities document 
    153         self._loadCapabilities 
     152        self._initCapabilities() 
     153        self._loadCapabilities() 
    154154         
    155155        # Render the capabilities document         
     
    157157        return self._renderCapabilities(version, format) 
    158158 
     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 
    159183 
    160184    def _renderCapabilities(self, version, format): 
    161185        """ 
    162186        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. 
    164189 
    165190        @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  
    66 
    77from genshi.builder import tag, Element 
     8from ows_common.pylons.genshi_util import RenameElementFilter 
     9from genshi import QName 
    810 
    911?> 
     
    1921  --> 
    2022 
    21   <Operation py:def="_opContent(op)" py:strip="True"> 
     23  <Operation py:def="_opContent(op)"> 
    2224    <Format py:for="f in op.parameters['Format'].possibleValues.allowedValues" py:content="f"/> 
    2325    <DCPType><HTTP> 
    24       <Get>OnlineResource xlink:href="${h.url_for()}?"</Get> 
     26      <Get><OnlineResource xlink:href="${op.get.href}"/></Get> 
    2527    </HTTP></DCPType> 
    2628  </Operation> 
    2729  <?python 
    2830   
    29   def markupOperation(op): 
     31  def markupOperation(opName, op): 
    3032    """Render an OWS operation description for the Capabilities section. 
    3133    """ 
    32     return Element(op.name)(_opContent(op).generate()) 
     34 
     35    return RenameElementFilter(QName(opName))(_opContent(op)) 
    3336 
    3437  ?> 
     
    6568 
    6669 
    67   <Service py:with="sm=c.service_metadata; si=c.service_metadata.serviceIdentification"> 
     70  <Service py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification"> 
    6871    <Name>WMS</Name> 
    6972    <Title py:content="si.titles[0]"/> 
     
    8689        <ContactAddress py:if="cn.address is not None"> 
    8790          <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> 
    8994          <City py:content="cn.address.city"/> 
    9095          <StateOrProvince py:content="cn.address.administrativeArea"/> 
     
    106111   
    107112  <!--! 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"> 
    109114    <py:if test="om is not None"> 
    110115      <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  
    44# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
    55""" 
    6 Utilities for constructing ows_common objects 
     6Utilities for OWS protocol processing. 
    77 
    88@author: Stephen Pascoe 
    99""" 
    1010 
    11 from ows_common.domain import Domain, PossibleValues 
    1211from 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 domain 
    19     @param possibleValues: Either a list of possible values, 
    20         a PossibleValues object or None to represent any value 
    21     @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 = possibleValues 
    27     else: 
    28         pv = PossibleValues.fromAllowedValues(possibleValues) 
    29  
    30     return Domain(defaultValue=value, possibleValues=pv, **kwargs) 
    31  
    32  
    3312 
    3413 
     
    8059            raise OWS_E.InvalidUpdateSequence 
    8160     
    82  
     61                      
    8362 
    8463#----------------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.