summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin/base.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugin/base.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/base.py b/src/lib/Bcfg2/Server/Plugin/base.py
index 3667c0e8f..ad5418d57 100644
--- a/src/lib/Bcfg2/Server/Plugin/base.py
+++ b/src/lib/Bcfg2/Server/Plugin/base.py
@@ -42,11 +42,23 @@ class Debuggable(object):
self.logger.error(message)
+class ClassName(object):
+ """ This very simple descriptor class exists only to get the name
+ of the owner class. This is used because, for historical reasons,
+ we expect every plugin to have a ``name`` attribute that is in
+ almost all cases the same as the ``__class__.__name__`` attribute
+ of the plugin object. This makes that more dynamic so that each
+ plugin isn't repeating its own name. """
+
+ def __get__(self, inst, owner):
+ return owner.__name__
+
+
class Plugin(Debuggable):
""" The base class for all Bcfg2 Server plugins. """
#: The name of the plugin.
- name = property(lambda s: s.__class__.__name__)
+ name = ClassName()
#: The email address of the plugin author.
__author__ = 'bcfg-dev@mcs.anl.gov'