From f73d976bdacae37557f0b2ccfa6da01ea58c685d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sun, 21 Sep 2008 21:50:56 +0000 Subject: 307: Split Plugin.finalize() into two steps 1) Plugin.set_api() and 2) Plugin.finalize(); updated unit tests --- ipalib/plugable.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'ipalib/plugable.py') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 19eae504..725833cd 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -340,17 +340,10 @@ class Plugin(ReadOnly): return False return True - def finalize(self, api): + def finalize(self): """ - After all the plugins are instantiated, `API` calls this method, - passing itself as the only argument. This is where plugins should - check that other plugins they depend upon have actually been loaded. - - :param api: An `API` instance. """ - assert self.__api is None, 'finalize() can only be called once' - assert api is not None, 'finalize() argument cannot be None' - self.__api = api + lock(self) def set_api(self, api): """ @@ -730,7 +723,9 @@ class API(DictProxy): object.__setattr__(self, name, namespace) for plugin in instances.itervalues(): - plugin.finalize(self) - lock(plugin) + plugin.set_api(self) assert plugin.api is self + + for plugin in instances.itervalues(): + plugin.finalize() object.__setattr__(self, '_API__finalized', True) -- cgit