From 3076cb4d2fa1be023a1c72d70cbdf5024047ff2a Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 30 Oct 2008 14:11:24 -0600 Subject: Plugin.set_api() now sets convience instance attributes from api for env, context, log, and all NameSpace --- ipalib/plugable.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ipalib/plugable.py') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 2f86fa22..d10ff797 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -351,6 +351,15 @@ class Plugin(ReadOnly): assert self.__api is None, 'set_api() can only be called once' assert api is not None, 'set_api() argument cannot be None' self.__api = api + if not isinstance(api, API): + return + for name in api: + assert not hasattr(self, name) + setattr(self, name, api[name]) + for name in ('env', 'context', 'log'): + if hasattr(api, name): + assert not hasattr(self, name) + setattr(self, name, getattr(api, name)) def __repr__(self): """ @@ -768,7 +777,7 @@ class API(DictProxy): self.env.log, self.env.verbose, ) - object.__setattr__(self, 'logger', logger) + object.__setattr__(self, 'log', logger) def load_plugins(self): """ -- cgit