From 74f5719078adfcfdf8b98bf97f0828dd150c840d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 1 Aug 2008 21:25:46 +0000 Subject: 42: plugable.Plugin.__init__() now takes the plugable.API instance as its single argument --- ipalib/plugable.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'ipalib/plugable.py') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 9025c1db..f298e97e 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -49,6 +49,16 @@ class Plugin(object): Base class for all plugins. """ + def __init__(self, api): + self.__api = api + + def __get_api(self): + """ + Returns the plugable.API object this plugin has been instatiated in. + """ + return self.__api + api = property(__get_api) + def __get_name(self): """ Returns the class name of this instance. @@ -132,6 +142,8 @@ class NameSpace(ReadOnly): def __init__(self, items): """ + `items` should be an iterable providing the members of this + NameSpace. """ object.__setattr__(self, '_NameSpace__items', tuple(items)) @@ -182,7 +194,6 @@ class NameSpace(ReadOnly): raise KeyError('NameSpace has no item for key %r' % key) - class Registrar(object): def __init__(self, *allowed): """ @@ -265,3 +276,9 @@ class Registrar(object): """ for base in self.__allowed: yield (base, self.__d[base.__name__].values()) + + +class API(ReadOnly): + def __init__(self, registrar): + for (base, plugins) in registrar: + pass -- cgit