From 6b6e6b1cab7a633faf16631a565ecb6988dadb48 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sat, 3 Jan 2009 17:27:53 -0700 Subject: Ported plugin registration errors into errors2.py; plugable.Registrar now raises new errors2 exceptions --- ipalib/plugable.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'ipalib/plugable.py') 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 -- cgit