summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xipa2
-rw-r--r--ipalib/plugable.py39
-rw-r--r--ipalib/public.py2
3 files changed, 24 insertions, 19 deletions
diff --git a/ipa b/ipa
index 18474d03..a4bc2cb0 100755
--- a/ipa
+++ b/ipa
@@ -52,7 +52,7 @@ def print_api():
for i in ns:
print ' %s %r' % (i.name.ljust(m), i)
- for n in ['cmd', 'obj', 'prop']:
+ for n in ['cmd', 'obj', 'mthd', 'prop']:
print_ns(n)
print ''
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 2c5fd18c..a8996cf2 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -236,10 +236,13 @@ class Registrar(object):
base; otherwise raises SubclassError.
"""
assert inspect.isclass(cls)
+ found = False
for base in self.__allowed:
if issubclass(cls, base):
- return base
- raise errors.SubclassError(cls, self.__allowed)
+ found = True
+ yield base
+ if not found:
+ raise errors.SubclassError(cls, self.__allowed)
def __call__(self, cls, override=False):
"""
@@ -248,27 +251,29 @@ class Registrar(object):
if not inspect.isclass(cls):
raise TypeError('plugin must be a class: %r' % cls)
- # Find the base class or raise SubclassError:
- base = self.__findbase(cls)
- sub_d = self.__d[base.__name__]
-
# Raise DuplicateError if this exact class was already registered:
if cls in self.__registered:
raise errors.DuplicateError(cls)
- # Check override:
- if cls.__name__ in sub_d:
- # Must use override=True to override:
- if not override:
- raise errors.OverrideError(base, cls)
- else:
- # There was nothing already registered to override:
- if override:
- raise errors.MissingOverrideError(base, cls)
+ # Find the base class or raise SubclassError:
+ for base in self.__findbase(cls):
+ sub_d = self.__d[base.__name__]
+
+ # Check override:
+ if cls.__name__ in sub_d:
+ # Must use override=True to override:
+ if not override:
+ raise errors.OverrideError(base, cls)
+ else:
+ # There was nothing already registered to override:
+ if override:
+ raise errors.MissingOverrideError(base, cls)
+
+ # The plugin is okay, add to sub_d:
+ sub_d[cls.__name__] = cls
- # The plugin is okay, add to __registered and sub_d:
+ # The plugin is okay, add to __registered:
self.__registered.add(cls)
- sub_d[cls.__name__] = cls
def __getitem__(self, item):
"""
diff --git a/ipalib/public.py b/ipalib/public.py
index 3bcf697f..e5e579f1 100644
--- a/ipalib/public.py
+++ b/ipalib/public.py
@@ -99,7 +99,7 @@ class PublicAPI(plugable.API):
__max_cmd_len = None
def __init__(self):
- super(PublicAPI, self).__init__(cmd, obj, prop)
+ super(PublicAPI, self).__init__(cmd, obj, mthd, prop)
def __get_max_cmd_len(self):
if self.__max_cmd_len is None: