From fe2e0a3ddbe05e5eace11268ddf909ed386438d0 Mon Sep 17 00:00:00 2001 From: Jonas Jochmaring Date: Fri, 22 May 2015 15:29:02 +0200 Subject: make Bcfg2-web compatible with django 1.7 - reports.wsgi uses get_wsgi_application() now - old south-based migrations have been moved - manage.py has been updated --- reports/reports.wsgi | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'reports') diff --git a/reports/reports.wsgi b/reports/reports.wsgi index 7113b3308..1a2a17f07 100644 --- a/reports/reports.wsgi +++ b/reports/reports.wsgi @@ -1,21 +1,23 @@ import os import Bcfg2.Options import Bcfg2.DBSettings +import django config_parsed = False -import django.core.handlers.wsgi +# with wsgi, the environment isn't present in os.environ, but +# is passwd to the application function +if 'BCFG2_CONFIG_FILE' in environ: + os.environ['BCFG2_CONFIG_FILE'] = environ['BCFG2_CONFIG_FILE'] +if not config_parsed: + Bcfg2.Options.get_parser().parse() + config_parsed = True -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 - if 'BCFG2_CONFIG_FILE' in environ: - 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) +if django.VERSION[0] == 1 and django.VERSION[1] >= 7: + from django.core.wsgi import get_wsgi_application + application = get_wsgi_application() +else: + def application(environ, start_response): + import django.core.handlers.wsgi + return django.core.handlers.wsgi.WSGIHandler()(environ, start_response) -- cgit v1.2.3-1-g7c22 From 07672ad6e6985b029c0ccf750f63576b488b95d7 Mon Sep 17 00:00:00 2001 From: Jonas Jochmaring Date: Mon, 6 Jul 2015 14:51:48 +0200 Subject: some more django 1.7 compatibility fixes --- reports/reports.wsgi | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'reports') diff --git a/reports/reports.wsgi b/reports/reports.wsgi index 1a2a17f07..05f28e3c8 100644 --- a/reports/reports.wsgi +++ b/reports/reports.wsgi @@ -5,19 +5,20 @@ import django config_parsed = False -# with wsgi, the environment isn't present in os.environ, but -# is passwd to the application function -if 'BCFG2_CONFIG_FILE' in environ: - os.environ['BCFG2_CONFIG_FILE'] = environ['BCFG2_CONFIG_FILE'] -if not config_parsed: - Bcfg2.Options.get_parser().parse() - config_parsed = True +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 + if 'BCFG2_CONFIG_FILE' in environ: + os.environ['BCFG2_CONFIG_FILE'] = environ['BCFG2_CONFIG_FILE'] + if not config_parsed: + Bcfg2.Options.get_parser().parse() + config_parsed = True -if django.VERSION[0] == 1 and django.VERSION[1] >= 7: - from django.core.wsgi import get_wsgi_application - application = get_wsgi_application() -else: - def application(environ, start_response): + if django.VERSION[0] == 1 and django.VERSION[1] >= 7: + from django.core.wsgi import get_wsgi_application + return get_wsgi_application()(environ, start_response) + else: import django.core.handlers.wsgi return django.core.handlers.wsgi.WSGIHandler()(environ, start_response) -- cgit v1.2.3-1-g7c22 From a505fb3b2df0d1eddfe7a92afb080b016e951a43 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 29 Sep 2015 23:11:44 +0200 Subject: Reports: Use try/except and no version comparison --- reports/reports.wsgi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'reports') diff --git a/reports/reports.wsgi b/reports/reports.wsgi index 05f28e3c8..979bcd389 100644 --- a/reports/reports.wsgi +++ b/reports/reports.wsgi @@ -1,7 +1,6 @@ import os import Bcfg2.Options import Bcfg2.DBSettings -import django config_parsed = False @@ -16,9 +15,9 @@ def application(environ, start_response): Bcfg2.Options.get_parser().parse() config_parsed = True - if django.VERSION[0] == 1 and django.VERSION[1] >= 7: + try: from django.core.wsgi import get_wsgi_application return get_wsgi_application()(environ, start_response) - else: + except ImportError: import django.core.handlers.wsgi return django.core.handlers.wsgi.WSGIHandler()(environ, start_response) -- cgit v1.2.3-1-g7c22