summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-15 03:41:17 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-15 03:41:17 +0000
commitdb8099febcb9c385eadfc4461dafa32df31bcbc0 (patch)
treee4ea2fa14cf1b20d04164c3796b8bd923ab1318b /ipalib/plugable.py
parent233293fb4a60d57e60bce67035a88f57b2cbf751 (diff)
downloadfreeipa-db8099febcb9c385eadfc4461dafa32df31bcbc0.tar.gz
freeipa-db8099febcb9c385eadfc4461dafa32df31bcbc0.tar.xz
freeipa-db8099febcb9c385eadfc4461dafa32df31bcbc0.zip
176: PluginProxy now subclasses from SetProxy
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index a891bab5e..c58114a94 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -351,7 +351,7 @@ class Plugin(ReadOnly):
)
-class PluginProxy(ReadOnly):
+class PluginProxy(SetProxy):
"""
Allows access to only certain attributes on a `Plugin`.
@@ -390,8 +390,8 @@ class PluginProxy(ReadOnly):
self.__public__ = base.__public__
self.name = getattr(target, name_attr)
self.doc = target.doc
- lock(self)
assert type(self.__public__) is frozenset
+ super(PluginProxy, self).__init__(self.__public__)
def implements(self, arg):
"""
@@ -411,31 +411,23 @@ class PluginProxy(ReadOnly):
"""
return self.__class__(self.__base, self.__target, name_attr)
- def __iter__(self):
- """
- Iterates (in ascending order) though the attribute names this proxy is
- allowing access to.
- """
- for name in sorted(self.__public__):
- yield name
-
def __getitem__(self, key):
"""
- If this proxy allows access to an attribute named `key`, return that
+ If this proxy allows access to an attribute named ``key``, return that
attribute.
"""
if key in self.__public__:
return getattr(self.__target, key)
- raise KeyError('no proxy attribute %r' % key)
+ raise KeyError('no public attribute %r' % key)
def __getattr__(self, name):
"""
- If this proxy allows access to an attribute named `name`, return that
- attribute.
+ If this proxy allows access to an attribute named ``name``, return
+ that attribute.
"""
if name in self.__public__:
return getattr(self.__target, name)
- raise AttributeError('no proxy attribute %r' % name)
+ raise AttributeError('no public attribute %r' % name)
def __call__(self, *args, **kw):
"""