summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/encoder.py10
-rw-r--r--ipalib/frontend.py10
-rw-r--r--ipalib/parameters.py33
-rw-r--r--ipalib/plugins/baseldap.py6
4 files changed, 9 insertions, 50 deletions
diff --git a/ipalib/encoder.py b/ipalib/encoder.py
index 8d59bd31..691f4d8c 100644
--- a/ipalib/encoder.py
+++ b/ipalib/encoder.py
@@ -79,7 +79,15 @@ class Encoder(object):
return self.encoder_settings.encode_postprocessor(
var.encode(self.encoder_settings.encode_to)
)
- elif isinstance(var, (bool, float, Decimal, int, long)):
+ elif isinstance(var, bool):
+ if var:
+ var = 'TRUE'
+ else:
+ var = 'FALSE'
+ return self.encoder_settings.encode_postprocessor(
+ var.encode(self.encoder_settings.encode_to)
+ )
+ elif isinstance(var, (float, Decimal, int, long)):
return self.encoder_settings.encode_postprocessor(
str(var).encode(self.encoder_settings.encode_to)
)
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index f6659634..b31d6d4b 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -429,8 +429,6 @@ class Command(HasParam):
if not self.api.env.in_server and 'version' not in params:
params['version'] = API_VERSION
self.validate(**params)
- if self.api.env.in_server:
- params = self.encode(**params)
(args, options) = self.params_2_args_options(**params)
ret = self.run(*args, **options)
if (
@@ -615,14 +613,6 @@ class Command(HasParam):
(k, self.params[k].convert(v)) for (k, v) in kw.iteritems()
)
- def encode(self, **kw):
- """
- Return a dictionary of encoded values.
- """
- return dict(
- (k, self.params[k].encode(v)) for (k, v) in kw.iteritems()
- )
-
def __convert_iter(self, kw):
for param in self.params():
if kw.get(param.name, None) is None:
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 35dbdd95..e9951a1c 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.
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index e4f8cdc6..85a81723 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -933,12 +933,6 @@ last, after all sets and adds."""),
raise errors.ValidationError(name=attr, error=err.error)
except errors.ConversionError, err:
raise errors.ConversionError(name=attr, error=err.error)
- # FIXME: We use `force` when encoding because we know this is
- # an attribute, even if it does not have the `attribute` flag
- # set. This happens with no_update attributes, which are
- # not cloned to Update commands. This cloning is where the flag
- # gets set.
- value = param.encode(value, force=True)
entry_attrs[attr] = value
else:
# unknown attribute: remove duplicite and invalid values