From efb4b669cb78155a17ecb4ec94be0d689e864332 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 6 Sep 2012 14:28:45 -0400 Subject: fixed Plugin auto-name magic --- src/lib/Bcfg2/Server/Plugin/base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') 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' -- cgit v1.2.3-1-g7c22