From 1a92bdf29b3c65d7b9bd1c61d9eda0f98a70ecfa Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 15 Aug 2008 01:32:20 +0000 Subject: 172: API now subclasses from DictProxy --- ipalib/plugable.py | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'ipalib') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index ba9b69739..4661aa1e6 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -674,7 +674,7 @@ class Registrar(ReadOnly): yield (base, tuple(sub_d[k] for k in sorted(sub_d))) -class API(ReadOnly): +class API(DictProxy): """ Dynamic API object through which `Plugin` instances are accessed. """ @@ -683,7 +683,7 @@ class API(ReadOnly): def __init__(self, *allowed): self.__d = dict() self.register = Registrar(*allowed) - lock(self) + super(API, self).__init__(self.__d) def finalize(self): """ @@ -713,30 +713,3 @@ class API(ReadOnly): lock(plugin) assert plugin.api is self object.__setattr__(self, '_API__finalized', True) - - def __len__(self): - """ - Returns the number of namespaces in this API. - """ - return len(self.__d) - - def __iter__(self): - """ - Iterates through the names of the namespaces in this API. - """ - for key in sorted(self.__d): - yield key - - def __contains__(self, key): - """ - Returns True if this API contains a `NameSpace` named ``key``. - """ - return key in self.__d - - def __getitem__(self, key): - """ - Returns the `NameSpace` instance named ``key``. - """ - if key in self.__d: - return self.__d[key] - raise KeyError('API has no NameSpace %r' % key) -- cgit