diff options
author | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-23 01:38:24 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-23 19:44:15 +0200 |
commit | f019e9254ec0c42f670fda7183c300263ee65c1e (patch) | |
tree | b602a66a95223e1efffe9aa448b6a616ab2b39f5 /tools | |
parent | 29533a0f52eac4f99e8e06a5ed49043eedd99e52 (diff) | |
download | bcfg2-f019e9254ec0c42f670fda7183c300263ee65c1e.tar.gz bcfg2-f019e9254ec0c42f670fda7183c300263ee65c1e.tar.bz2 bcfg2-f019e9254ec0c42f670fda7183c300263ee65c1e.zip |
Reporting: Do not use django.db.backend in newer django versions
The private API django.db.backend is deprecated in django 1.7 and removed in
django 1.8, so we use another way to get the DatabaseOperations from the
connection.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/upgrade/1.3/migrate_dbstats.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py index c788aae37..8911266fb 100755 --- a/tools/upgrade/1.3/migrate_dbstats.py +++ b/tools/upgrade/1.3/migrate_dbstats.py @@ -9,7 +9,8 @@ import time import Bcfg2.Logger import Bcfg2.Options from Bcfg2.DBSettings import get_db_label -from django.db import transaction, backend, connections +import django +from django.db import transaction, connections from Bcfg2.Server.Admin import UpdateReports from Bcfg2.Reporting.utils import BatchFetch from Bcfg2.Reporting.Compat import transaction @@ -28,11 +29,15 @@ def _quote(value): """ global _our_backend if not _our_backend: - try: - _our_backend = backend.DatabaseOperations( - connections[get_db_label('Reporting')]) - except TypeError: - _our_backend = backend.DatabaseOperations() + if django.VERSION[0] == 1 and django.VERSION[1] >= 7: + _our_backend = connections[get_db_label('Reporting')].ops + else: + from django.db import backend + try: + _our_backend = backend.DatabaseOperations( + connections[get_db_label('Reporting')]) + except TypeError: + _our_backend = backend.DatabaseOperations() return _our_backend.quote_name(value) |