Changeset 4408 for cows


Ignore:
Timestamp:
03/11/08 16:36:55 (11 years ago)
Author:
domlowe
Message:

More prototype support for stored queries.

Location:
cows/trunk/cows
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/model/storedquery.py

    r4398 r4408  
    2020     
    2121class QueryExpressionText(object): 
    22     def __init__(self, returnFeatureTypes, language=None, any=None, isPrivate=False): 
    23         self.returnFeatureTypes=returnFeatureTypes 
     22    def __init__(self, returnFeatureType, language=None, any=None, isPrivate=False): 
     23        self.returnFeatureType=returnFeatureType 
    2424        self.language=language 
    2525        self.any=any 
  • cows/trunk/cows/pylons/templates/wfs_capabilities_2_0_0.xml

    r4398 r4408  
    106106    <py:if test="om is not None"> 
    107107      <?python 
    108         ops = ['GetCapabilities', 'DescribeFeature', 'GetFeature', 'DescribeStoredQueries'] 
     108        ops = ['GetCapabilities', 'DescribeFeature', 'GetFeature', 'DescribeStoredQueries', 'ListStoredQueries'] 
    109109        eops = [x for x in om.operationDict.keys() if x not in ops] 
    110110      ?> 
  • cows/trunk/cows/pylons/templates/wfs_describestoredqueries.xml

    r4398 r4408  
    55?> 
    66 
    7 <wfs:DescribeStoredQueriesResponse xmlns:py="http://genshi.edgewall.org/" 
    8                   xmlns:wfs="http://www.opengis.net/wfs" 
     7<DescribeStoredQueriesResponse xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.opengis.net/wfs"   
    98                  xmlns:gml="http://www.opengis.net/gml">        
    10         <wfs:query py:for="query in c.storedqueries" 
     9        <query py:for="query in c.storedqueries" 
    1110             py:content="query"/> 
    12 </wfs:DescribeStoredQueriesResponse> 
     11</DescribeStoredQueriesResponse> 
  • cows/trunk/cows/pylons/wfs_controller.py

    r4400 r4408  
    4040 
    4141    service = 'WFS' 
    42     owsOperations = (ows_controller.OWSController.owsOperations + ['DescribeFeatureType', 'GetFeature', 'DescribeStoredQueries']) 
     42    owsOperations = (ows_controller.OWSController.owsOperations + ['DescribeFeatureType', 'GetFeature', 'DescribeStoredQueries','ListStoredQueries']) 
    4343    validVersions = ['1.1.0', '2.0.0'] 
    4444     
     
    114114 
    115115            c.capabilities.contents.datasetSummaries.append(ds) 
    116  
    117     def _buildStoredQueries(self): 
    118         return self.layerMapper.queryDescriptions.queries 
    119116 
    120117    def _getSchema(self, typename): 
     
    169166        queryxml=self.getOwsParam('query',default=None) 
    170167        storedqueryid=self.getOwsParam('storedquery_id', default=None) 
     168         
     169        #TODO get any other parameters from self._owsParams and pass them to the stored query        
    171170        if queryxml: 
    172171            qp=FEQueryProcessor() 
     
    175174        elif storedqueryid: 
    176175            storedquery, func=self.layerMapper.queryDescriptions.queries[storedqueryid] 
    177             c.resultset=func(arg1='cat', arg2='dog') 
     176            c.resultset=func(self.featureset, arg1='cat', arg2='dog') 
    178177            log.debug('Final resultset from stored query %s'%c.resultset) 
    179178        else: 
     
    185184        return t.generate(c=c).render()             
    186185 
    187  
    188      
     186    
    189187    def DescribeStoredQueries(self): 
    190188        """ DescribeStoredQueries method. Takes zero or more stored query ids as args""" 
    191         c.storedqueries = self._buildStoredQueries() 
     189        allqueries=self.layerMapper.queryDescriptions.queries         
     190        storedqueryid=self.getOwsParam('storedqueryid', default=None) 
     191        if storedqueryid is None: 
     192            c.storedqueries = self.layerMapper.queryDescriptions.queries 
     193        else: 
     194            c.storedqueries={} 
     195            for queryid in storedqueryid.split(','): 
     196                c.storedqueries[queryid]=self.layerMapper.queryDescriptions.queries[queryid]        
    192197        t = ows_controller.templateLoader.load('wfs_describestoredqueries.xml') 
    193198        return t.generate(c=c).render()   
    194199          
     200    def ListStoredQueries(self): 
     201        """ DescribeStoredQueries method. Takes zero or more stored query ids as args""" 
     202        c.storedqueries = self.layerMapper.queryDescriptions.queries 
     203        t = ows_controller.templateLoader.load('wfs_liststoredqueries.xml') 
     204        return t.generate(c=c).render()  
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4400 r4408  
    8787    def __init__(self): 
    8888        #self.queries is a dictionary of form: {id:(StoredQuery, func)} 
    89         #where func is the name of the implementation of the stored query (typically) in wfs_csmlstoredqueries 
     89        #where func is the name of the implementation of the stored query (typically) in wfs_csmlstoredqueries       
    9090        self.queries={} 
    91         qid='queryOne' 
    92         query=StoredQuery(qid) 
     91        qid='queryOne'         
     92        qet=QueryExpressionText('csml:PointSeriesFeature') #TODO, possibly this could differ for different features... 
     93        query=StoredQuery(qid, queryExpressionText = qet) 
    9394        self.queries[qid]=(query, CSMLQueries.query_one_func) 
     95         
    9496        qid='queryTwo' 
    95         query=StoredQuery(qid) 
     97        qet=QueryExpressionText('csml:GridSeriesFeature') #TODO, possibly this could differ for different features... 
     98        query=StoredQuery(qid,queryExpressionText = qet) 
    9699        self.queries[qid]=(query, CSMLQueries.query_two_func)       
    97          
    98100 
    99101class CSMLFeatureSet(IFeatureSet): 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r4400 r4408  
    1212        return '<someGML>%s</someGML>'%self.x 
    1313 
    14 def query_one_func(arg1=None, arg2=None): 
     14def query_one_func(featureset, arg1=None, arg2=None): 
    1515    result = [dummyfeaturefortesting('blah1')] 
    1616    return result 
    1717 
    18 def query_two_func(arg1=None, arg2=None): 
     18def query_two_func(featureset, arg1=None, arg2=None): 
    1919    result = [dummyfeaturefortesting('blah2')] 
    2020    return result 
Note: See TracChangeset for help on using the changeset viewer.