Module: check_mk
Branch: master
Commit: 86a13a6d3c5a7db0fbd202e8118808f8dd508f70
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=86a13a6d3c5a7d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 16 09:55:46 2018 +0200
Plugin registry: Add explicit registering method and decorator
* Plugins will be changed to register explicitly with the registry
* The automatic plugin discovery will be dropped later
Change-Id: Iea9a89c92eda06ac5cab796a577269fbf92f5521
---
cmk/gui/plugin_registry.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/cmk/gui/plugin_registry.py b/cmk/gui/plugin_registry.py
index ddd68bc..ce29a44 100644
--- a/cmk/gui/plugin_registry.py
+++ b/cmk/gui/plugin_registry.py
@@ -35,8 +35,9 @@ class Registry(object):
The snapins are loaded by importing cmk.gui.plugins.[component]. These plugins
contain subclasses of the cmk.gui.plugins.PluginBase (e.g. SidebarSnpain) class.
- Registry.load_plugins() will register all snapins with this management
- object and make them available for use.
+
+ Entries are registered with this registry using either the register_plugin()
+ method or the Registry.register() decorator.
"""
__metaclass__ = abc.ABCMeta
@@ -79,6 +80,20 @@ class Registry(object):
@abc.abstractmethod
def register(self, plugin_class):
+ """Decorator to register a class with the
registry"""
+ self._register(plugin_class)
+
+
+ @abc.abstractmethod
+ def register_plugin(self, plugin_class):
+ """Method for registering a plugin with the registry.
+
+ Result is equal to use the register() decorator"""
+ self._register(plugin_class)
+
+
+ @abc.abstractmethod
+ def _register(self, plugin_class):
raise NotImplementedError()