I'd like to access the GEOIP_COUNTRY_CODE
environment variable from 开发者_如何学编程within Django running on mod_wsgi in daemon mode. The problem is, I can see the variable from within PHP scripts running on the server but it seems that it is not passed through WSGI to my Django site.
request.META.get('GEOIP_COUNTRY_CODE')
does not work.
Is there something like WSGIPassAuthorization
for additional environment variables in mod_wsgi?
If the variable is set by the extension module as an environment variable, then it will be accessible as:
import os
value = os.environ['GEOIP_COUNTRY_CODE']
Ie., just like any other environment variable.
UPDATE 1:
If set inside of an Apache module however such as mod_geoip, the only way it would be transfered into WSGI application realm is if it is set in req.subprocess_env of Apache request structure. Ie., the same as if SetEnv directive had been used with Apache. In that case it should appear in the WSGI environ dictionary passed to the WSGI application.
To try and validate whether this is occuring, using WSGI echo test script shown in:
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Displaying_Request_Environment
精彩评论