diff options
author | Michael Fenn <fennm@deshawresearch.com> | 2014-04-09 10:59:58 -0400 |
---|---|---|
committer | Michael Fenn <fennm@deshawresearch.com> | 2014-04-09 10:59:58 -0400 |
commit | b527fed1109c958dcb39c3a45c4789379ada39e0 (patch) | |
tree | a2f0dbafa9e8a44c9a4091b2e384598bf7bdc209 | |
parent | 86c26ab4f06df46d24719e3b62aa92aa1d696881 (diff) | |
download | bcfg2-b527fed1109c958dcb39c3a45c4789379ada39e0.tar.gz bcfg2-b527fed1109c958dcb39c3a45c4789379ada39e0.tar.bz2 bcfg2-b527fed1109c958dcb39c3a45c4789379ada39e0.zip |
Parse the config inside of the wsgi application function
If you don't set this, the parsing code will always look in
/etc/bcfg2.conf for the config, which might not exist or be readable by
apache in a standard config.
-rw-r--r-- | reports/reports.wsgi | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/reports/reports.wsgi b/reports/reports.wsgi index 75eb78c0b..711f64712 100644 --- a/reports/reports.wsgi +++ b/reports/reports.wsgi @@ -3,10 +3,19 @@ import Bcfg2.Options import Bcfg2.DBSettings os.environ['DJANGO_SETTINGS_MODULE'] = 'Bcfg2.DBSettings' - -Bcfg2.Options.get_parser().parse() +config_parsed = False import django.core.handlers.wsgi + def application(environ, start_response): + global config_parsed + + # with wsgi, the environment isn't present in os.environ, but + # is passwd to the application function + os.environ['BCFG2_CONFIG_FILE'] = environ['BCFG2_CONFIG_FILE'] + if not config_parsed: + Bcfg2.Options.get_parser().parse() + config_parsed = True + return django.core.handlers.wsgi.WSGIHandler()(environ, start_response) |