summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index 696dacc06..2a68ea3b7 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -11,9 +11,14 @@ import sys
import threading
import Bcfg2.Server
from Bcfg2.Bcfg2Py3k import ConfigParser
-
import Bcfg2.Options
+try:
+ import django
+ has_django = True
+except ImportError:
+ has_django = False
+
# py3k compatibility
if sys.hexversion >= 0x03000000:
from functools import reduce
@@ -106,6 +111,20 @@ class DatabaseBacked(object):
def __init__(self):
pass
+ @property
+ def _use_db(self):
+ use_db = self.core.setup.cfp.getboolean(self.name.lower(),
+ "use_database",
+ default=False)
+ if use_db and has_django:
+ return True
+ elif not use_db:
+ return False
+ else:
+ self.logger.error("use_database is true but django not found")
+ return False
+
+
class PluginDatabaseModel(object):
class Meta: