diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-15 01:32:20 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-15 01:32:20 +0000 |
commit | 1a92bdf29b3c65d7b9bd1c61d9eda0f98a70ecfa (patch) | |
tree | 9df3557c5ab9097bc01455b2a264b5804fba1127 /ipalib/plugable.py | |
parent | e43a5c642e1717c9309e8747e5433ab85abf2779 (diff) | |
download | freeipa-1a92bdf29b3c65d7b9bd1c61d9eda0f98a70ecfa.tar.gz freeipa-1a92bdf29b3c65d7b9bd1c61d9eda0f98a70ecfa.tar.xz freeipa-1a92bdf29b3c65d7b9bd1c61d9eda0f98a70ecfa.zip |
172: API now subclasses from DictProxy
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 31 |
1 files changed, 2 insertions, 29 deletions
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) |