From 1431c80b3c2a256bb6c10cf042f7671004695a9f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 10 Apr 2012 07:44:21 -0400 Subject: Convert --setattr values for attributes marked no_update Attribute Patrams marked no_update never get cloned to Update commands, and thus never receive the `attribute` flag. This makes their `encode` method a no-op, which meant they don't get properly encoded when used with --setattr, making the --setattr fail. Introduce a `force` argument to encode, which overrides checking for the attribute flag. Use this in set/add/delattr normalization, where we know we are dealing with attributes. https://fedorahosted.org/freeipa/ticket/2616 --- ipalib/parameters.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ipalib/parameters.py') diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 60fb5023..5c55d8bc 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -895,7 +895,7 @@ class Param(ReadOnly): rule=rule, ) - def encode(self, value): + def encode(self, value, force=False): """ Encode Python native type value to chosen backend format. Encoding is applied for parameters representing actual attributes (attribute=True). @@ -909,8 +909,10 @@ class Param(ReadOnly): `Param._encode()`. :param value: Encoded value + :param force: If set to true, encoding takes place even for Params + not marked as attribute """ - if not self.attribute: #pylint: disable=E1101 + if not self.attribute and not force: #pylint: disable=E1101 return value if self.encoder is not None: #pylint: disable=E1101 return self.encoder(value) #pylint: disable=E1101 -- cgit