diff options
author | Rob Austein <sra@hactrn.net> | 2014-09-16 18:29:46 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-09-16 18:29:46 +0000 |
commit | 180a9c09f9705283e11caa2df408e6b2353f3b9d (patch) | |
tree | a0861ddd006017e9f4fe754bd1abefa36a9a73cb /rpki/gui/script_util.py | |
parent | c02686daf6dcc4175f119adc5d19261f577b2856 (diff) | |
parent | 7c2fb9ca36f120369797072e534041daae6cd8f9 (diff) |
Merge changes from branches/tk713 into branches/tk705. See #705, #713.
svn path=/branches/tk705/; revision=5956
Diffstat (limited to 'rpki/gui/script_util.py')
-rw-r--r-- | rpki/gui/script_util.py | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/rpki/gui/script_util.py b/rpki/gui/script_util.py index 46545d83..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$' @@ -29,16 +24,28 @@ 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'), + } + }, + ) |