source: TI07-MOLES/trunk/PythonCode/wsgi/wsgiEnv.py @ 2046

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/PythonCode/wsgi/wsgiEnv.py@2522
Revision 2046, 924 bytes checked in by lawrence, 13 years ago (diff)

Mainly test code to understand browse deployment environment (plus tiny
bug fix in browse docuemnt retrieval).

Line 
1#
2# this simple wsgi routine is available for testing the environment within which
3# wsgi is operating, and is intended to be used with wsgiEnv.ini
4#
5def wsgiEnvFactory(global_config,**kw):
6    ''' This factory is intended to be used by paste-deploy to return
7    a wsgiEnv instance '''
8    app=wsgiEnv()
9    return app
10
11class wsgiEnv:
12    ''' Simply produces an html list of the wsgi environment variables '''
13    def __init__(self,**kw):
14        pass
15   
16    def __call__(self,environ,start_response):
17        html=self.get(environ)
18        start_response('200 OK', [('Content-Type', 'text/html')])
19        return [html]
20       
21    def get(self,environ):
22        ''' Provided as a method so it can be used as a function, not only as
23        wsgi middleware '''
24        html='<ul>'
25        for item in environ.keys():
26            html+='<li>%s:%s'%(item,environ[item])
27        html+='</ul>'
28        return html
29       
Note: See TracBrowser for help on using the repository browser.