2009/11/27 Aljosa Mohorovic <
aljosa.m...@gmail.com>:
Using environment variables for arbitrary configuration is a bad idea.
To understand some of the problems with doing that in Python in multi
interpreter process environment read:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Environment_Variables
What you could instead do is:
import os
import wsgi_app.settings as settings
settings.PROJECT_ROOT = PROJECT_ROOT
settings.DATABASE_ENGINE = 'sqlite3',
settings.DATABASE_NAME = os.path.join(PROJECT_ROOT, 'dev.db')
os.environ['DJANGO_SETTINGS_MODULE'] = 'wsgi_app.settings'
In other words, have WSGI script file import your baseline settings
file and then override the values in it from WSGI script file by way
of assignment. Then set DJANGO_SETTINGS_MODULE as per normal etc.
Dangers of this are that you might have password database information
in WSGI script file. Technically WSGI script file is going to be
marked as a file that Apache can serve up to clients. Normally it
doesn't serve the content and instead the content is interpreted by
mod_wsgi, but stuff up your Apache configuration bad and you
inadvertently provide a way of it being able to be requested by a
client as a static file.
As such, always better to keep sensitive configuration information out
of the WSGI script file. If you are confident in your ability to
configure Apache, then no problems.
BTW, what most would do is have multiple settings files in project,
ie., development_settings.py, production_settings.py, etc. These would
do 'from settings import *' then they would override values. The
DJANGO_SETTINGS_MODULE for production would then specify
'wsgi_app.production_settings'.
Graham