diff options
author | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2016-11-21 19:13:07 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2016-11-21 19:13:07 +0100 |
commit | f500167d2aae88d9b2a68fb792a9cad797a9338b (patch) | |
tree | 2eac96384c7a89e01e606e0d32020801006e886e /src/lib/Bcfg2 | |
parent | 255faafd7f98b80e39d742483fd284a7a962062a (diff) | |
download | bcfg2-f500167d2aae88d9b2a68fb792a9cad797a9338b.tar.gz bcfg2-f500167d2aae88d9b2a68fb792a9cad797a9338b.tar.bz2 bcfg2-f500167d2aae88d9b2a68fb792a9cad797a9338b.zip |
Reporting/Storage: Load django models after option parsing
django get setup during option parsing and we cannot acces
"django.db.models" before. So we need to delay the import of the models
until the option parsing is ready.
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Reporting/Storage/DjangoORM.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py index 27040feb6..cdfab7704 100644 --- a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py +++ b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py @@ -20,13 +20,23 @@ from django.core.cache import cache #Used by GetCurrentEntry import difflib from Bcfg2.Compat import b64decode -from Bcfg2.Reporting.models import \ - Interaction, PackageEntry, FilePerms, PathEntry, LinkEntry, \ - Group, Client, Bundle, TYPE_EXTRA, TYPE_BAD, TYPE_MODIFIED, \ - FailureEntry, Performance, BaseEntry from Bcfg2.Reporting.Compat import transaction +def load_django_models(): + """ Load models for Django after option parsing has completed """ + # pylint: disable=W0602 + global Interaction, PackageEntry, FilePerms, PathEntry, LinkEntry, \ + Group, Client, Bundle, TYPE_EXTRA, TYPE_BAD, TYPE_MODIFIED, \ + FailureEntry, Performance, BaseEntry + # pylint: enable=W0602 + + from Bcfg2.Reporting.models import \ + Interaction, PackageEntry, FilePerms, PathEntry, LinkEntry, \ + Group, Client, Bundle, TYPE_EXTRA, TYPE_BAD, TYPE_MODIFIED, \ + FailureEntry, Performance, BaseEntry + + def get_all_field_names(model): if django.VERSION[0] == 1 and django.VERSION[1] >= 8: return [field.name @@ -45,6 +55,7 @@ class DjangoORM(StorageBase): type=Bcfg2.Options.Types.size, help='Reporting file size limit', default=1024 * 1024)] + options_parsed_hook = staticmethod(load_django_models) def _import_default(self, entry, state, entrytype=None, defaults=None, mapping=None, boolean=None, xforms=None): |