1.15.4.3 web.wsgi.environment - Environment Information

The web.wsgi.environment module provides one class Environment which adds the following information to the environ dictionary based on the parameters specified in the class constructor.

environ['web.environment.name']
A string containing the name of the environment

environ['web.environment.type']
A string containing the type of the environment. This can currently only be 'database'

Middleware or applications further down the chain can access these variables as follows:

import web.wsgi.base, web.wsgi.environment

class Application(web.wsgi.base.BaseApplication):
    def start(self):
        self.output('<html>')
        self.output('<p>Name: %s</p>'%self.environ['web.environment.name'])
        self.output('<p>Type: %s</p>'%self.environ['web.environment.type'])
        self.output('</html>')

application = web.wsgi.environment.Environment(
    Application(),
    name='testEnv',
    type='database',
)