Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/PythonCode/wsgi/DiscoveryState.py@1955
Revision 1955,
1.2 KB
checked in by lawrence, 14 years ago
(diff) |
More improvements to wsgi discovery, some unit tests, improved
namespace handling in DIF.py ...
|
Line | |
---|
1 | from paste.request import parse_querystring,construct_url |
---|
2 | class DiscoveryState: |
---|
3 | ''' This class holds the state associated with presenting multiple slices |
---|
4 | of a large result set ''' |
---|
5 | def __init__(self,sessionID,environ,hits,offset=1,stride=10): |
---|
6 | ''' On instantiation, provide |
---|
7 | the backend sessionID |
---|
8 | the application URL that produced this query |
---|
9 | the stride through the result set ''' |
---|
10 | self.environ=environ # the wsgi environment |
---|
11 | self.sessID=sessionID |
---|
12 | self.hits=hits |
---|
13 | self.offset=offset |
---|
14 | self.stride=stride |
---|
15 | def geturl(self,**kw): |
---|
16 | ''' Get a url from the wsgi environment, modified by the keyword arguments offset and stride |
---|
17 | which are to be part of the querystring ''' |
---|
18 | args=dict(parse_querystring(self.environ)) |
---|
19 | offset,stride=kw.get('offset'),kw.get('stride') |
---|
20 | if offset is not None:args['start']=offset |
---|
21 | if stride is not None:args['howmany']=stride |
---|
22 | q='' |
---|
23 | for i in args: q+='%s=%s&'%(i,args[i]) |
---|
24 | q=q[0:-1] |
---|
25 | url=construct_url(self.environ, with_query_string=True, with_path_info=True, querystring=q) |
---|
26 | return url |
---|
27 | |
---|
Note: See
TracBrowser
for help on using the repository browser.