diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 17:27:53 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 17:27:53 -0700 |
commit | 6b6e6b1cab7a633faf16631a565ecb6988dadb48 (patch) | |
tree | 86b5b24485955ac3186beb7e350b77c47fefa5b3 /ipalib/plugable.py | |
parent | d1517b95ca14773773647434fb589c8224307328 (diff) | |
download | freeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.tar.gz freeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.tar.xz freeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.zip |
Ported plugin registration errors into errors2.py; plugable.Registrar now raises new errors2 exceptions
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 4ef2135b5..094634d33 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -34,6 +34,7 @@ import os from os import path import subprocess import errors +import errors2 from config import Env import util from base import ReadOnly, NameSpace, lock, islocked, check_name @@ -461,7 +462,9 @@ class Registrar(DictProxy): found = True yield (base, sub_d) if not found: - raise errors.SubclassError(klass, self.__allowed.keys()) + raise errors2.PluginSubclassError( + plugin=klass, bases=self.__allowed.keys() + ) def __call__(self, klass, override=False): """ @@ -471,11 +474,11 @@ class Registrar(DictProxy): :param override: If true, override an already registered plugin. """ if not inspect.isclass(klass): - raise TypeError('plugin must be a class: %r' % klass) + raise TypeError('plugin must be a class; got %r' % klass) # Raise DuplicateError if this exact class was already registered: if klass in self.__registered: - raise errors.DuplicateError(klass) + raise errors2.PluginDuplicateError(plugin=klass) # Find the base class or raise SubclassError: for (base, sub_d) in self.__findbases(klass): @@ -483,11 +486,19 @@ class Registrar(DictProxy): if klass.__name__ in sub_d: if not override: # Must use override=True to override: - raise errors.OverrideError(base, klass) + raise errors2.PluginOverrideError( + base=base.__name__, + name=klass.__name__, + plugin=klass, + ) else: if override: # There was nothing already registered to override: - raise errors.MissingOverrideError(base, klass) + raise errors2.PluginMissingOverrideError( + base=base.__name__, + name=klass.__name__, + plugin=klass, + ) # The plugin is okay, add to sub_d: sub_d[klass.__name__] = klass |