diff options
author | Rob Austein <sra@hactrn.net> | 2014-10-05 01:15:55 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-10-05 01:15:55 +0000 |
commit | d4f19b6a2957b11d286b1306cc1b209ee18e200c (patch) | |
tree | 7ec4338c4c19034e1669b1c1ffaddb647f867263 | |
parent | 24635430e46c2fad0bdb5fb12fe18e212f76c437 (diff) |
Address incompatible API changes in Django 1.7: apps.populate(),
MIDDLEWARE_CLASSES. Fixes #717.
svn path=/trunk/; revision=5986
-rwxr-xr-x | ca/irbe_cli | 7 | ||||
-rw-r--r-- | ca/tests/yamlconf.py | 7 | ||||
-rw-r--r-- | rpki/gui/script_util.py | 6 | ||||
-rw-r--r-- | rpki/irdbd.py | 11 | ||||
-rw-r--r-- | rpki/rpkic.py | 7 |
5 files changed, 37 insertions, 1 deletions
diff --git a/ca/irbe_cli b/ca/irbe_cli index 1becd403..91c12aa9 100755 --- a/ca/irbe_cli +++ b/ca/irbe_cli @@ -322,6 +322,8 @@ while argv: argv = q_pdu.client_getopt(argv[1:]) q_msg.append(q_pdu) +import django + from django.conf import settings settings.configure( @@ -334,8 +336,13 @@ settings.configure( "PORT" : "", "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, INSTALLED_APPS = ("rpki.irdb",), + MIDDLEWARE_CLASSES = (), ) +if django.VERSION >= (1, 7): + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) + import rpki.irdb server_ca = rpki.irdb.ServerCA.objects.get() diff --git a/ca/tests/yamlconf.py b/ca/tests/yamlconf.py index 1b339a89..f1073c92 100644 --- a/ca/tests/yamlconf.py +++ b/ca/tests/yamlconf.py @@ -773,13 +773,20 @@ def body(): databases["default"] = databases[db.root.irdb_name] + import django + from django.conf import settings settings.configure( DATABASES = databases, DATABASE_ROUTERS = ["rpki.irdb.router.DBContextRouter"], + MIDDLEWARE_CLASSES = (), INSTALLED_APPS = ("rpki.irdb",)) + if django.VERSION >= (1, 7): # API change, feh + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) + import rpki.irdb rpki.irdb.models.ca_certificate_lifetime = rpki.sundial.timedelta(days = 3652 * 2) diff --git a/rpki/gui/script_util.py b/rpki/gui/script_util.py index c3a864fd..fb15403d 100644 --- a/rpki/gui/script_util.py +++ b/rpki/gui/script_util.py @@ -16,6 +16,8 @@ This module contains utility functions for use in standalone scripts. """ +import django + from django.conf import settings from rpki import config @@ -40,4 +42,8 @@ def setup(): 'PASSWORD': cfg.get('sql-password'), } }, + MIDDLEWARE_CLASSES = (), ) + if django.VERSION >= (1, 7): + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) diff --git a/rpki/irdbd.py b/rpki/irdbd.py index d53ae67c..ae08b6fb 100644 --- a/rpki/irdbd.py +++ b/rpki/irdbd.py @@ -186,6 +186,9 @@ class main(object): def main(self): global rpki # pylint: disable=W0602 + + import django + from django.conf import settings startup_msg = self.cfg.get("startup-message", "") @@ -211,7 +214,13 @@ class main(object): "PASSWORD" : self.cfg.get("sql-password"), "HOST" : "", "PORT" : "" }}, - INSTALLED_APPS = ("rpki.irdb",),) + INSTALLED_APPS = ("rpki.irdb",), + MIDDLEWARE_CLASSES = (), # API change, feh + ) + + if django.VERSION >= (1, 7): # API change, feh + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) import rpki.irdb # pylint: disable=W0621 diff --git a/rpki/rpkic.py b/rpki/rpkic.py index d7b76c51..8ce28b59 100644 --- a/rpki/rpkic.py +++ b/rpki/rpkic.py @@ -132,6 +132,8 @@ class main(Cmd): self.histfile = cfg.get("history_file", os.path.expanduser("~/.rpkic_history")) self.autosync = cfg.getboolean("autosync", True, section = "rpkic") + import django + from django.conf import settings settings.configure( @@ -144,8 +146,13 @@ class main(Cmd): "PORT" : "", "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, INSTALLED_APPS = ("rpki.irdb",), + MIDDLEWARE_CLASSES = (), # API change, feh ) + if django.VERSION >= (1, 7): # API change, feh + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) + import rpki.irdb # pylint: disable=W0621 try: |