From 57534ca5a0f5443c80ffba4c1640650a5989c7b8 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 6 Aug 2008 15:54:27 +0000 Subject: [PATCH] 63: Started fleshing out public.cmd --- ipalib/public.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ipalib/public.py b/ipalib/public.py index 941011b6f..5c413ab09 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -41,10 +41,35 @@ class cmd_proxy(plugable.Proxy): class cmd(plugable.Plugin): proxy = cmd_proxy + __opt = None def get_doc(self, _): + """ + Returns the gettext translated doc-string for this command. + + For example: + + >>> def get_doc(self, _): + >>> return _('add new user') + """ raise NotImplementedError('%s.get_doc()' % self.name) + def get_options(self): + """ + Returns iterable with opt_proxy objects used to create the opt + NameSpace when __get_opt() is called. + """ + raise NotImplementedError('%s.get_options()' % self.name) + + def __get_opt(self): + """ + Returns the NameSpace containing opt_proxy objects. + """ + if self.__opt is None: + self.__opt = plugable.NameSpace(self.get_options()) + return self.__opt + opt = property(__get_opt) + def __call__(self, *args, **kw): print repr(self)