[uWSGI] WSGI environment vs. process environment

Roberto De Ioris roberto at unbit.it
Sat Nov 27 23:29:02 CET 2010


> Is there a way to insert entries into the WSGI environment from uwsgi's
> configuration? --env seems to only update the process environment.
>
>   $ uwsgi --ini wsgitest.ini --env my_config=test.cfg
> *** Starting uWSGI 0.9.6.5 (64bit) on [Sat Nov 27 16:50:39 2010] ***
> [snip]
> (Epdb) self.environ.get('my_config')
> None
> (Epdb) os.getenv('my_config')
> 'test.cfg'
>
> Compare mod_wsgi, where apache's SetEnv directive affects the WSGI
> environment.
>

You can do it in nginx via uwsgi_param directive, and in cherokee clicking
on the 'add cgi variables' button.

On the apache mod_Ruwsgi (the alternative implementation of mod_uwsgi) you
can use the SetEnv directive as mod_wsgi.

There is currently no way (AFAIK) for doing it in lighttpd.

Remember that you can inject variables via WSGI middleware:

def application(e, sr):
   e['NEW_VAR'] = 'value01'
   e['SECOND_NEW_VAR'] = 'value02'
   return real_application(e, sr)

-- 
Roberto De Ioris
http://unbit.it


More information about the uWSGI mailing list