diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-08-01 14:55:10 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-08-14 12:08:27 +0200 |
commit | 7804a74826eebd1ed07bc9eaa28c1eb9bff5a3f7 (patch) | |
tree | f6a17744f3b2276976eb9372544304e3c9aaee20 /ipalib/plugins/ping.py | |
parent | a8d2ec6677d97907c84751242620a3198484dc7b (diff) | |
download | freeipa-7804a74826eebd1ed07bc9eaa28c1eb9bff5a3f7.tar.gz freeipa-7804a74826eebd1ed07bc9eaa28c1eb9bff5a3f7.tar.xz freeipa-7804a74826eebd1ed07bc9eaa28c1eb9bff5a3f7.zip |
Allow API plugin registration via a decorator
This makes plugin registration easier to read, less error-prone, and,
for many Plugins in a single module, faster to write.
Functionally, the decorator is equivalent to current plugin
registration. However, in the future this style will allow cleaner
semantics.
As an example, and to exercise the new syntax to prevent regressions,
the ping plugin is converted to this style.
Diffstat (limited to 'ipalib/plugins/ping.py')
-rw-r--r-- | ipalib/plugins/ping.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ipalib/plugins/ping.py b/ipalib/plugins/ping.py index 0743758f..52da5d4b 100644 --- a/ipalib/plugins/ping.py +++ b/ipalib/plugins/ping.py @@ -17,10 +17,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from ipalib import api from ipalib import Command from ipalib import output from ipalib import _, ngettext +from ipalib.plugable import Registry from ipapython.version import VERSION, API_VERSION __doc__ = _(""" @@ -51,6 +51,10 @@ EXAMPLES: ----------------------------------------------------- """) +register = Registry() + + +@register() class ping(Command): __doc__ = _('Ping a remote server.') @@ -64,5 +68,3 @@ class ping(Command): back but a fixed value works for now. """ return dict(summary=u'IPA server version %s. API version %s' % (VERSION, API_VERSION)) - -api.register(ping) |