Changeset 3548 for TI05-delivery


Ignore:
Timestamp:
29/02/08 13:58:46 (12 years ago)
Author:
spascoe
Message:

Added a simple data interface for WMS. This may not live in ows_common
in the long term but is the most convenient place to put it for now.

Location:
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/ows_controller.py

    r3496 r3548  
    3232 
    3333# Instantiate Genshi template loader 
    34 genshiLoader = TemplateLoader( 
     34templateLoader = TemplateLoader( 
    3535    resource_filename('ows_common.pylons', 'templates'), 
    3636    auto_reload=True, 
     
    4444 
    4545 
    46 class OwsControllerBase(WSGIController): 
     46class OWSControllerBase(WSGIController): 
    4747    """ 
    4848    @ivar owsParams: A dictionary of parameters passed to the service. 
     
    6363        if 'pylons' in EXCEPTION_TYPE: 
    6464            self._fixOwsAction(environ) 
    65             return super(OwsControllerBase, self).__call__(environ, start_response) 
     65            return super(OWSControllerBase, self).__call__(environ, start_response) 
    6666        else: 
    6767            try: 
    6868                self._fixOwsAction(environ) 
    69                 return super(OwsControllerBase, self).__call__(environ, start_response) 
     69                return super(OWSControllerBase, self).__call__(environ, start_response) 
    7070            except OWS_E.OwsError, e: 
    7171                logger.exception(e) 
    7272 
    73                 tmpl = genshiLoader.load('exception_report.xml') 
     73                tmpl = templateLoader.load('exception_report.xml') 
    7474                response.write(tmpl.generate(report=e.report).render('xml')) 
    7575                response.headers['content-type'] = 'text/xml' 
     
    116116def addOperation(opName, formats=[]): 
    117117    ops = c.capabilities.operationsMetadata.operationDict 
    118     ops[opName] = helpers.operation(url_for(), formats=formats) 
    119  
    120 def addLayer(name, title, abstract, srs, bbox, dimensions={}): 
     118    ops[opName] = helpers.operation(url_for(qualified=True, action="index")+'?', formats=formats) 
     119 
     120def addLayer(name, title, abstract, srss, bbox, dimensions={}): 
    121121    """ 
    122122    @param dimensions: Dictionary of dictionaries D[k1][k2]=val where 
     
    131131        c.capabilities.contents = Contents() 
    132132 
    133     layer = helpers.wms_layer(name, title, srs, bbox, abstract) 
     133    layer = helpers.wms_layer(name, title, srss, bbox, abstract) 
    134134 
    135135    for k1, kwargs in dimensions.items(): 
     
    159159#----------------------------------------------------------------------------- 
    160160 
    161 class OwsController(OwsControllerBase): 
    162     """ 
    163     Adds basic GetCapabilities response to OwsControllerBase. 
     161class OWSController(OWSControllerBase): 
     162    """ 
     163    Adds basic GetCapabilities response to OWSControllerBase. 
    164164 
    165165    @cvar service: If None does not enforce the SERVICE parameter.  Otherwise 
     
    175175    owsOperations = ['GetCapabilities'] 
    176176 
    177     # Override these attributes to control how OwsController responds to 
     177    # Override these attributes to control how OWSController responds to 
    178178    # GetCapabilities 
    179179    service = None 
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_capabilities_1_1_1.xml

    r3496 r3548  
    11<?xml version="1.0"?> 
    22<!DOCTYPE WMT_MS_Capabilities SYSTEM 
    3  "http://www.digitalearth.gov/wmt/xml/capabilities_1_1_1.dtd"> 
     3 "http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd"> 
    44 
    55<?python 
     
    88from ows_common.pylons.genshi_util import RenameElementFilter 
    99from genshi import QName 
     10import webhelpers as h 
    1011 
    1112?> 
    1213 
    1314<WMT_MS_Capabilities xmlns:py="http://genshi.edgewall.org/" 
    14                      xmlns:xlink="http://www.w3.org/1999/xlink" 
    1515                     version="1.1.1"> 
    1616 
     
    2424    <Format py:for="f in op.parameters['Format'].possibleValues.allowedValues" py:content="f"/> 
    2525    <DCPType><HTTP> 
    26       <Get><OnlineResource xlink:href="${op.get.href}"/></Get> 
     26      <Get> 
     27        <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"  
     28                        xlink:href="${op.get.href}"/> 
     29      </Get> 
    2730    </HTTP></DCPType> 
    2831  </Operation> 
     
    6063      <Dimension name="${d_n}" units="${d.valuesUnit}" 
    6164                 unitSymbol="${d.unitSymbol}"/> 
    62       <Extent name="${d_n}" default="${d.defaultValue}" nearestValue="${d.nearestValue}" 
    63               py:content="' '.join(d.possibleValues.allowedValues)"/> 
     65      <Extent name="${d_n}" default="${d.defaultValue}" nearestValue="${int(d.nearestValue)}" 
     66              py:content="','.join(d.possibleValues.allowedValues)"/> 
    6467    </py:for> 
    6568  </Layer> 
     
    7679               py:content="kw"/> 
    7780    </KeywordList> 
    78     <!--! <OnlineResource xlink:type="simple" xlink:href="${h.url_for()}"/> --> 
     81    <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"  
     82                    xlink:href="${h.url_for(qualified=True, action='index')}?"/> 
    7983     
    8084    <ContactInformation py:if="sm.serviceProvider is not None" 
     
    8286      <ContactPersonPrimary> 
    8387        <ContactPerson py:if="rp is not None" py:content="rp.individualName"/> 
    84         <ContactOrganisation py:content="sm.serviceProvider.providerName"/> 
     88        <ContactOrganization py:content="sm.serviceProvider.providerName"/> 
    8589      </ContactPersonPrimary> 
    8690      <ContactPosition py:content="rp.positionName"/> 
     
    113117  <Capability py:with="sm=c.capabilities; om=sm.operationsMetadata"> 
    114118    <py:if test="om is not None"> 
    115       <py:for each="opName, op in om.operationDict.items()"> 
    116         <Request py:content="markupOperation(opName, op)"/> 
    117         <?python exceptions = op.parameters.get('ExceptionFormat') ?> 
    118         <Exception py:if="exceptions is not None"> 
    119           <Format py:for="e in exceptions.possibleValues.allowedValues" 
    120                   py:content="e"/> 
    121         </Exception> 
    122       </py:for> 
     119      <?python ops = ['GetCapabilities', 'GetMap', 'GetFeatureInfo'] ?> 
     120      <Request> 
     121        <py:for each="opName in ops" py:if="opName in om.operationDict.keys()"> 
     122          <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/> 
     123        </py:for> 
     124        <py:for each="opName in ops" py:if="opName in om.operationDict.keys()"> 
     125          <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?> 
     126          <Exception py:if="exceptions is not None"> 
     127            <Format py:for="e in exceptions.possibleValues.allowedValues" 
     128                    py:content="e"/> 
     129          </Exception> 
     130        </py:for> 
     131      </Request> 
    123132    </py:if> 
    124133     
     134    <!--!TODO:  capability exceptions --> 
     135    <Exception><Format>text/xml</Format></Exception> 
     136 
    125137    <Layer py:if="sm.contents is not None"> 
    126138      <Title>Contents</Title> 
    127139      <Layer py:for="ds in sm.contents.datasetSummaries" 
    128              py:replace="markupLayer(ds)"/> 
     140             py:replace="markupLayer(ds)"> 
     141      </Layer> 
    129142    </Layer> 
    130143  </Capability> 
Note: See TracChangeset for help on using the changeset viewer.