From 1ca764a9456512a3dbdcbf83e4a337cdfc982dbe Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 14 Sep 2014 00:28:56 +0000 Subject: Start backing out all the old settings.configure() calls, which were indeed masking the new migration stuff. yamltest now runs migrations as part of setting up test CAs; still need to decide whether running migrations in production is something that should be handled explicitly via rpki-manage or should be bundled into rpki-sql-setup. Old settings.configure() code still present as a trail of breadcrumbs to follow when backing out the rest of the tortuous startup sequence required by the old way of doing things. svn path=/branches/tk713/; revision=5950 --- rpki/gui/script_util.py | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'rpki/gui/script_util.py') diff --git a/rpki/gui/script_util.py b/rpki/gui/script_util.py index c3a864fd..678ddae6 100644 --- a/rpki/gui/script_util.py +++ b/rpki/gui/script_util.py @@ -16,11 +16,6 @@ This module contains utility functions for use in standalone scripts. """ -from django.conf import settings - -from rpki import config -from rpki import autoconf - __version__ = '$Id$' @@ -28,16 +23,29 @@ def setup(): """ Configure Django enough to use the ORM. """ - cfg = config.parser(section='web_portal') - # INSTALLED_APPS doesn't seem necessary so long as you are only accessing - # existing tables. - settings.configure( - DATABASES={ - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': cfg.get('sql-database'), - 'USER': cfg.get('sql-username'), - 'PASSWORD': cfg.get('sql-password'), - } - }, - ) + + # In theory we no longer need to call settings.configure, which + # probably means this whole module can go away soon, but leave + # breadcrumbs for now. + + if True: + os.environ.update(DJANGO_SETTINGS_MODULE = "rpki.django_settings") + + else: + from rpki import config + from rpki import autoconf + from django.conf import settings + + cfg = config.parser(section='web_portal') + # INSTALLED_APPS doesn't seem necessary so long as you are only accessing + # existing tables. + settings.configure( + DATABASES={ + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': cfg.get('sql-database'), + 'USER': cfg.get('sql-username'), + 'PASSWORD': cfg.get('sql-password'), + } + }, + ) -- cgit v1.2.3