summaryrefslogtreecommitdiffstats
path: root/ipalib/parameters.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-06-02 07:31:12 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commit0e989e2a28fb8093528176574ffd2ae2ecac4c14 (patch)
tree8fa1f0542a995198b30dac97fc114a1cab6c0322 /ipalib/parameters.py
parent98ede1b0e8c8473d6910fab2328dbc81d740945c (diff)
downloadfreeipa-0e989e2a28fb8093528176574ffd2ae2ecac4c14.tar.gz
freeipa-0e989e2a28fb8093528176574ffd2ae2ecac4c14.tar.xz
freeipa-0e989e2a28fb8093528176574ffd2ae2ecac4c14.zip
parameters: introduce no_convert keyword argument
When set to true, the argument causes params to not convert unicode values to the param type. This will allow thin client to properly handle params which can be converted from unicode to the param type only on the server, e.g. because of a normalizer. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib/parameters.py')
-rw-r--r--ipalib/parameters.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index f574456cf..ccbf6e349 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -414,6 +414,7 @@ class Param(ReadOnly):
('sortorder', int, 2), # see finalize()
('option_group', unicode, None),
('cli_metavar', str, None),
+ ('no_convert', bool, False),
# The 'default' kwarg gets appended in Param.__init__():
# ('default', self.type, None),
@@ -808,18 +809,26 @@ class Param(ReadOnly):
:param value: A proposed value for this parameter.
"""
+ if not self.no_convert:
+ convert = self._convert_scalar
+ else:
+ def convert(value):
+ if isinstance(value, unicode):
+ return value
+ return self._convert_scalar(value)
+
if _is_null(value):
return
if self.multivalue:
if type(value) not in (tuple, list):
value = (value,)
values = tuple(
- self._convert_scalar(v) for v in value if not _is_null(v)
+ convert(v) for v in value if not _is_null(v)
)
if len(values) == 0:
return
return values
- return self._convert_scalar(value)
+ return convert(value)
def _convert_scalar(self, value, index=None):
"""