summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-15 11:50:15 +0000
committerJan Cholasta <jcholast@redhat.com>2015-07-01 13:05:30 +0000
commitb1fc875c3ac74be91df8f1cf8b4369b77a156677 (patch)
treefbcb652feb59a27c6c86c3e41c22446cc975987d /ipalib/plugable.py
parent860088208bfc9b8f0300b5688c79b78dd4644e5d (diff)
downloadfreeipa-b1fc875c3ac74be91df8f1cf8b4369b77a156677.tar.gz
freeipa-b1fc875c3ac74be91df8f1cf8b4369b77a156677.tar.xz
freeipa-b1fc875c3ac74be91df8f1cf8b4369b77a156677.zip
plugable: Lock API on finalization rather than on initialization
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 770897d70..5050416b5 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -433,8 +433,6 @@ class API(ReadOnly):
self.modules = modules
self.__done = set()
self.env = Env()
- if not is_production_mode(self):
- lock(self)
def __len__(self):
"""
@@ -501,14 +499,14 @@ class API(ReadOnly):
self.__doing('bootstrap')
self.env._bootstrap(**overrides)
self.env._finalize_core(**dict(DEFAULT_CONFIG))
- object.__setattr__(self, 'log_mgr', log_mgr)
+ self.log_mgr = log_mgr
log = log_mgr.root_logger
- object.__setattr__(self, 'log', log)
+ self.log = log
# Add the argument parser
if not parser:
parser = self.build_global_parser()
- object.__setattr__(self, 'parser', parser)
+ self.parser = parser
# If logging has already been configured somewhere else (like in the
# installer), don't add handlers or change levels:
@@ -796,7 +794,7 @@ class API(ReadOnly):
if not production_mode:
assert not hasattr(self, name)
- object.__setattr__(self, name, NameSpace(members))
+ setattr(self, name, NameSpace(members))
for klass, instance in plugins.iteritems():
if not production_mode:
@@ -806,10 +804,11 @@ class API(ReadOnly):
if not production_mode:
assert islocked(instance)
- object.__setattr__(self, '_API__finalized', True)
- object.__setattr__(self, 'plugins',
- tuple((k, tuple(v)) for k, v in plugin_info.iteritems())
- )
+ self.__finalized = True
+ self.plugins = tuple((k, tuple(v)) for k, v in plugin_info.iteritems())
+
+ if not production_mode:
+ lock(self)
class IPAHelpFormatter(optparse.IndentedHelpFormatter):