summaryrefslogtreecommitdiffstats
path: root/ipalib/parameter.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-05 01:20:14 -0700
committerJason Gerard DeRose <jderose@redhat.com>2009-01-05 01:20:14 -0700
commitc121d0064bb7a7bd1a289ae29ceb2dee314c2d2f (patch)
treeb4e324b210818dde55b8b78f0820a102ae4cdd06 /ipalib/parameter.py
parent026860bd5652286af64a82d3d52582701af44c0b (diff)
downloadfreeipa.git-c121d0064bb7a7bd1a289ae29ceb2dee314c2d2f.tar.gz
freeipa.git-c121d0064bb7a7bd1a289ae29ceb2dee314c2d2f.tar.xz
freeipa.git-c121d0064bb7a7bd1a289ae29ceb2dee314c2d2f.zip
New Param: Added Param.get_label() method for a way to retrieve translated message at request time
Diffstat (limited to 'ipalib/parameter.py')
-rw-r--r--ipalib/parameter.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ipalib/parameter.py b/ipalib/parameter.py
index 55a9bc6d..93a9a693 100644
--- a/ipalib/parameter.py
+++ b/ipalib/parameter.py
@@ -23,6 +23,7 @@ Parameter system for command plugins.
from types import NoneType
from util import make_repr
+from request import ugettext
from plugable import ReadOnly, lock, check_name
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
@@ -199,6 +200,7 @@ class Param(ReadOnly):
kwargs = (
('cli_name', str, None),
+ ('label', callable, None),
('doc', str, ''),
('required', bool, True),
('multivalue', bool, False),
@@ -301,6 +303,14 @@ class Param(ReadOnly):
**self.__kw
)
+ def get_label(self):
+ """
+ Return translated label using `request.ugettext`.
+ """
+ if self.label is None:
+ return self.cli_name.decode('UTF-8')
+ return self.label(ugettext)
+
def normalize(self, value):
"""
Normalize ``value`` using normalizer callback.