summaryrefslogtreecommitdiffstats
path: root/ipalib/parameters.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-06-02 15:58:43 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commit3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36 (patch)
tree35d9b5235752fca82159e5e12d99d75225c15b3b /ipalib/parameters.py
parent0e989e2a28fb8093528176574ffd2ae2ecac4c14 (diff)
downloadfreeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.tar.gz
freeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.tar.xz
freeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.zip
ipalib: replace DeprecatedParam with `deprecated` Param argument
Introduce new `deprecated` Param keywork argument. Setting it to True on a param has the same effect as using DeprecatedParam. This allows deprecating params while retaining their type information. Revert all DeprecatedParam params back to their original definition and set `deprecated` to True. Remove the now unused DeprecatedParam class. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib/parameters.py')
-rw-r--r--ipalib/parameters.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index ccbf6e349..196300295 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -415,6 +415,7 @@ class Param(ReadOnly):
('option_group', unicode, None),
('cli_metavar', str, None),
('no_convert', bool, False),
+ ('deprecated', bool, False),
# The 'default' kwarg gets appended in Param.__init__():
# ('default', self.type, None),
@@ -871,6 +872,10 @@ class Param(ReadOnly):
if error is not None:
raise ValidationError(name=self.get_param_name(), error=error)
+ def _rule_deprecated(self, _, value):
+ if self.deprecated:
+ return _('this option is deprecated')
+
def get_default(self, **kw):
"""
Return the static default or construct and return a dynamic default.
@@ -1870,22 +1875,6 @@ class DNParam(Param):
return dn
-class DeprecatedParam(Any):
- kwargs = Param.kwargs + (
- ('deprecate', bool, True),
- )
-
- def __init__(self, name, *rules, **kw):
- if 'flags' in kw:
- kw['flags'] = list(kw['flags']) + ['no_option']
- else:
- kw['flags'] = ['no_option']
-
- super(DeprecatedParam, self).__init__(name, *rules, **kw)
-
- def _rule_deprecate(self, _, value):
- return _('this option is deprecated')
-
def create_param(spec):
"""
Create an `Str` instance from the shorthand ``spec``.