Ignore:
Timestamp:
28/07/07 15:39:13 (13 years ago)
Author:
lawrence
Message:

Fixes for ticket:818

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DiscoveryState.py

    r2745 r2750  
    11from paste.request import parse_querystring,construct_url 
    22import cgi 
     3class constraints: 
     4    ''' A container object for constraints on a search ''' 
     5    def __init__(self, **kw): 
     6        self.values={} 
     7        keys=['dateRange','bbox','scope','textTarget','searchString'] 
     8        for key in keys:self.values[key]=None 
     9        print kw 
     10        for k in kw: self[k]=kw[k] 
     11             
     12    def __setitem__(self,key,value): 
     13        if key in self.values: 
     14            self.values[key]=value 
     15        else: 
     16            raise ValueError('Unknown key [%s] in constraints') 
     17     
     18    def __getitem__(self,key): 
     19        if key in self.values:  
     20            return self.values[key] 
     21        else: 
     22            raise ValueError('Unknown key [%s] in constraints'%key) 
     23     
     24    def __str__(self): 
     25        c='' 
     26        if self.values['dateRange'] is not None: 
     27            dr=self.values['dateRange']  
     28            c+='Including %s to %s; '%('%s,%s,%s'%dr[0],'%s,%s,%s'%dr[1]) 
     29        bbox=self.values['bbox'] 
     30        if bbox is None or bbox==['+90.0','-90.0','-180.0','+180.0']: 
     31            c+='Global; ' 
     32        else: c+='Bounding Box: %s,%s,%s,%s; '%tuple(bbox) 
     33        if self.values['scope'] is not None or self.values['textTarget'] is not None: 
     34            c+='Restricted to ' 
     35        if self.values['scope'] is not None: c+='%s; '%self.values['scope'] 
     36        if self.values['textTarget'] is not None: c+='%s; '%self.values['textTarget'] 
     37        return c[:-2] 
     38 
    339class DiscoveryState: 
    4     ''' This class holds the state associated with presenting multiple slices 
    5     of a large result set ''' 
     40    ''' This class holds the state associated with a search (including presenting multiple slices 
     41    of a large result set) ''' 
    642    def __init__(self,sessionID,searchString,environ,hits,constraints,offset=1,stride=10): 
    743        ''' On instantiation, provide 
     
    1046                the stride through the result set ''' 
    1147        self.environ=environ # the wsgi environment 
    12         self.constraints=constraints # some text to show constraints on search 
     48        self.constraintsInstance=constraints 
     49        self.constraints=str(constraints) # some text to show constraints on search 
     50        self.constrainedurl=self.geturl()+'&constrained' 
    1351        self.sessID=sessionID 
    1452        self.hits=hits 
Note: See TracChangeset for help on using the changeset viewer.