diff options
author | Jan Cholasta <jcholast@redhat.com> | 2015-06-22 10:59:35 +0000 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-07-01 13:05:30 +0000 |
commit | 4b277d04771bece11f5cc9fe04cc04d3f2ded165 (patch) | |
tree | 050034eff53e762a494490b0aeb5df8e24a133a0 /ipalib/plugable.py | |
parent | 1a21fd971ccc26cf8f06d1ba965b263856be56c6 (diff) | |
download | freeipa-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/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 22 |
1 files changed, 9 insertions, 13 deletions
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 = {} |