diff options
author | Jonas Jochmaring <jjonas@mail.upb.de> | 2015-07-06 14:51:48 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-23 19:28:57 +0200 |
commit | 07672ad6e6985b029c0ccf750f63576b488b95d7 (patch) | |
tree | 80dd70e96f611aa434f07e30e72c88dd5181f53b | |
parent | fe2e0a3ddbe05e5eace11268ddf909ed386438d0 (diff) | |
download | bcfg2-07672ad6e6985b029c0ccf750f63576b488b95d7.tar.gz bcfg2-07672ad6e6985b029c0ccf750f63576b488b95d7.tar.bz2 bcfg2-07672ad6e6985b029c0ccf750f63576b488b95d7.zip |
some more django 1.7 compatibility fixes
-rw-r--r-- | reports/reports.wsgi | 25 | ||||
-rw-r--r-- | src/lib/Bcfg2/DBSettings.py | 3 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Admin.py | 5 |
3 files changed, 19 insertions, 14 deletions
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) diff --git a/src/lib/Bcfg2/DBSettings.py b/src/lib/Bcfg2/DBSettings.py index bff24ffce..80e6caf20 100644 --- a/src/lib/Bcfg2/DBSettings.py +++ b/src/lib/Bcfg2/DBSettings.py @@ -65,7 +65,8 @@ settings = dict( # pylint: disable=C0103 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.request'), - DATABASE_ROUTERS=['Bcfg2.DBSettings.PerApplicationRouter']) + DATABASE_ROUTERS=['Bcfg2.DBSettings.PerApplicationRouter'], + TEST_RUNNER='django.test.simple.DjangoTestSuiteRunner') if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] >= 7: settings['INSTALLED_APPS'] += ('Bcfg2.Reporting',) diff --git a/src/lib/Bcfg2/Server/Admin.py b/src/lib/Bcfg2/Server/Admin.py index 0eba843c7..b7ee0c0ed 100644 --- a/src/lib/Bcfg2/Server/Admin.py +++ b/src/lib/Bcfg2/Server/Admin.py @@ -32,7 +32,7 @@ try: HAS_DJANGO = True if django.VERSION[0] == 1 and django.VERSION[1] >= 7: HAS_REPORTS = True - elif django.VERSION[0] == 1 and django.VERSION[1] <= 6: + else: try: import south # pylint: disable=W0611 HAS_REPORTS = True @@ -904,6 +904,9 @@ if HAS_DJANGO: class Syncdb(AdminCmd): """ Sync the Django ORM with the configured database """ + if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] >= 7: + django.setup() + def run(self, setup): Bcfg2.Server.models.load_models() try: |