summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-22 10:59:35 +0000
committerJan Cholasta <jcholast@redhat.com>2015-07-01 13:05:30 +0000
commit4b277d04771bece11f5cc9fe04cc04d3f2ded165 (patch)
tree050034eff53e762a494490b0aeb5df8e24a133a0 /ipalib
parent1a21fd971ccc26cf8f06d1ba965b263856be56c6 (diff)
downloadfreeipa-4b277d04771bece11f5cc9fe04cc04d3f2ded165.tar.gz
freeipa-4b277d04771bece11f5cc9fe04cc04d3f2ded165.tar.xz
freeipa-4b277d04771bece11f5cc9fe04cc04d3f2ded165.zip
plugable: Change is_production_mode to method of API
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py4
-rw-r--r--ipalib/plugable.py22
2 files changed, 11 insertions, 15 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index c36bfca46..af201fc9a 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -27,7 +27,7 @@ from distutils import version
from ipapython.version import API_VERSION
from ipapython.ipa_log_manager import root_logger
from base import NameSpace
-from plugable import Plugin, is_production_mode
+from plugable import Plugin
from parameters import create_param, Param, Str, Flag, Password
from output import Output, Entry, ListOfEntries
from text import _
@@ -359,7 +359,7 @@ class HasParam(Plugin):
self._filter_param_by_context(name, env),
sort=False
)
- if not is_production_mode(self):
+ if not self.api.is_production_mode():
check = getattr(self, 'check_' + name, None)
if callable(check):
check(namespace)
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 9e7e4fc3b..967246f10 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -49,17 +49,6 @@ from ipapython.version import VERSION, API_VERSION
# FIXME: Updated constants.TYPE_ERROR to use this clearer format from wehjit:
TYPE_ERROR = '%s: need a %r; got a %r: %r'
-def is_production_mode(obj):
- """
- If the object has self.env.mode defined and that mode is
- production return True, otherwise return False.
- """
- if getattr(obj, 'env', None) is None:
- return False
- if getattr(obj.env, 'mode', None) is None:
- return False
- return obj.env.mode == 'production'
-
# FIXME: This function has no unit test
def find_modules_in_dir(src_dir):
@@ -184,7 +173,7 @@ class Plugin(ReadOnly):
self.__finalize_called = True
self._on_finalize()
self.__finalized = True
- if not is_production_mode(self):
+ if not self.__api.is_production_mode():
lock(self)
def _on_finalize(self):
@@ -368,6 +357,13 @@ class API(ReadOnly):
except AttributeError:
raise KeyError(name)
+ def is_production_mode(self):
+ """
+ If the object has self.env.mode defined and that mode is
+ production return True, otherwise return False.
+ """
+ return getattr(self.env, 'mode', None) == 'production'
+
def __doing(self, name):
if name in self.__done:
raise StandardError(
@@ -664,7 +660,7 @@ class API(ReadOnly):
self.__doing('finalize')
self.__do_if_not_done('load_plugins')
- production_mode = is_production_mode(self)
+ production_mode = self.is_production_mode()
plugins = {}
plugin_info = {}