From b527fed1109c958dcb39c3a45c4789379ada39e0 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Wed, 9 Apr 2014 10:59:58 -0400 Subject: 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. --- reports/reports.wsgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'reports') 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) -- cgit v1.2.3-1-g7c22