i'm trying to setup a django application using modwsgi
in the daemon mode,
and i need to make sure the locale is set up correctly,
meaning sys.environment['LANG'] is 'en_US.utf8',
and not 'C'.
what is the recommended way to do this?
should i do it in my python-wsgi script with
"
sys.environment['LANG'] = 'en_US.utf8'
"
or is there a way to do it in the apache config file?
in the past i was using mod_fcgid, and there i could
set environment variables with something like this:
RewriteRule .* - [E=name:value]
but it does not seem to work here.
thanks,
gabor
You mean:
os.environ['LANG'] = 'en_US.utf8'
I am not sure that will work if this is done from WSGI script file as
it may be too late if it was needed to be set when Python was being
first initialised.
> or is there a way to do it in the apache config file?
No, can't be done in Apache configuration file.
> in the past i was using mod_fcgid, and there i could
> set environment variables with something like this:
> RewriteRule .* - [E=name:value]
>
> but it does not seem to work here.
This only works for FASTCGI/SCGI/CGI because they fork off separate
processes when needed and the SetEnv variables become process level
environment variables. In mod_wsgi the SetEnv variables are specific
to the WSGI environment dictionary passed to the WSGI application and
don't affect the whole process.
The only way I know that is 100% guaranteed to work is for stock
standard Apache installation, ie., from original source code, you
modify the 'envvars' file that should be in same directory as the
'httpd' executable. In this you would add:
LANG='en_US.utf8'
export LANG
On Linux distributions with packaged Apache, this file doesn't
generally exist. The only solution in that case is to modify the init
startup file for Apache service and add it there instead.
Graham
yes :)
>
> The only way I know that is 100% guaranteed to work is for stock
> standard Apache installation, ie., from original source code, you
> modify the 'envvars' file that should be in same directory as the
> 'httpd' executable. In this you would add:
>
> LANG='en_US.utf8'
> export LANG
>
> On Linux distributions with packaged Apache, this file doesn't
> generally exist. The only solution in that case is to modify the init
> startup file for Apache service and add it there instead.
i'm running debian lenny, and '/etc/apache2/envvars' exists there.
i added
EXPORT LANG=en_US.utf8
to it, and it sends it correctly to the python wsgi application.
thanks for the help,
gabor