Plugin.set_api() now sets convience instance attributes from api for env, context, log, and all NameSpace

This commit is contained in:
Jason Gerard DeRose committed 2008-10-30 14:11:24 -06:00
1 parent 6879140db7
commit 3076cb4d2f
2 files changed
+11 -2

No files matched your search

+10 -1
View File
@@ -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):
"""
+1 -1
View File
@@ -147,7 +147,7 @@ if __name__ == '__main__':
api.bootstrap(context='server')
api.load_plugins()
api.finalize()
logger = api.logger
logger = api.log
# Set up the server
XMLRPCServer = StoppableXMLRPCServer(