aboutsummaryrefslogtreecommitdiff
path: root/rpki/gui/script_util.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-09-14 00:28:56 +0000
committerRob Austein <sra@hactrn.net>2014-09-14 00:28:56 +0000
commit1ca764a9456512a3dbdcbf83e4a337cdfc982dbe (patch)
tree41652de28b3bf53f4aba4dfac42ca9c7c305e4fb /rpki/gui/script_util.py
parent773d3c3d01f39b1cedb7506ee7c1c3ceed91a17d (diff)
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
Diffstat (limited to 'rpki/gui/script_util.py')
-rw-r--r--rpki/gui/script_util.py44
1 files changed, 26 insertions, 18 deletions
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'),
+ }
+ },
+ )