summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-05-25 12:54:53 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commit1391cd65ad87e70b9544c11cf8c9d22f54df2902 (patch)
tree244133595c3e25ea1b56c1ca23eacabda241199c /ipalib/plugable.py
parent19cf6e950943725986bca5732e343c3a793f5b70 (diff)
downloadfreeipa-1391cd65ad87e70b9544c11cf8c9d22f54df2902.tar.gz
freeipa-1391cd65ad87e70b9544c11cf8c9d22f54df2902.tar.xz
freeipa-1391cd65ad87e70b9544c11cf8c9d22f54df2902.zip
plugable: remember overriden plugins in API
Remember what plugin class was overriden by what plugin class in API objects. Add new method API.get_plugin_next which returns the plugin class which was overriden by the plugin class specified as argument. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index ed63ec646..b248a2c28 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -267,6 +267,7 @@ class API(ReadOnly):
def __init__(self):
super(API, self).__init__()
self.__plugins = {}
+ self.__next = {}
self.__done = set()
self.env = Env()
@@ -593,6 +594,8 @@ class API(ReadOnly):
name=klass.__name__,
plugin=klass,
)
+
+ self.__next[klass] = prev
else:
if override:
# There was nothing already registered to override:
@@ -653,6 +656,12 @@ class API(ReadOnly):
if not production_mode:
lock(self)
+ def get_plugin_next(self, klass):
+ if not inspect.isclass(klass):
+ raise TypeError('plugin must be a class; got %r' % klass)
+
+ return self.__next[klass]
+
class IPAHelpFormatter(optparse.IndentedHelpFormatter):
def format_epilog(self, text):