From d9d196798945bef7a955acb8b71820800455be17 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Fri, 4 May 2012 10:34:00 -0400 Subject: Redo boolean value encoding. Move the code for encoding boolean values to LDAP boolean syntax from the Parameter class to the Encoder class, where the rest of LDAP encoding takes place. Remove encoding code from the Parameter class altogether, as all LDAP encoding should be done in the Encoder class. --- ipalib/parameters.py | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'ipalib/parameters.py') diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 35dbdd957..e9951a1c8 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -306,8 +306,6 @@ class Param(ReadOnly): - primary_key: Command's parameter primary key is used for unique identification of an LDAP object and for sorting - normalizer: a custom function for Param value normalization - - encoder: a custom function used to override Param subclass default - encoder - default_from: a custom function for generating default values of parameter instance - autofill: by default, only `required` parameters get a default value @@ -381,7 +379,6 @@ class Param(ReadOnly): ('multivalue', bool, False), ('primary_key', bool, False), ('normalizer', callable, None), - ('encoder', callable, None), ('default_from', DefaultFrom, None), ('autofill', bool, False), ('query', bool, False), @@ -901,36 +898,6 @@ class Param(ReadOnly): rule=rule, ) - 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). - - The default encode method `Param._encode` can be overriden in a `Param` - instance with `encoder` attribute: - - >>> s = Str('my_str', encoder=lambda x:encode(x)) - - Note that the default method of encoding values is defined in - `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 and not force: #pylint: disable=E1101 - return value - if self.encoder is not None: #pylint: disable=E1101 - return self.encoder(value) #pylint: disable=E1101 - - return self._encode(value) - - def _encode(self, value): - """ - Encode a value to backend format. - """ - return value - def get_default(self, **kw): """ Return the static default or construct and return a dynamic default. -- cgit