diff options
author | Jan Cholasta <jcholast@redhat.com> | 2012-05-04 10:34:00 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-05-09 09:43:35 +0200 |
commit | d9d196798945bef7a955acb8b71820800455be17 (patch) | |
tree | fcdbbb63b26640f9255a264b62d53248e8e11ba1 /ipalib/encoder.py | |
parent | abef5e8c027bf37d9522f4d30e8e43c408251893 (diff) | |
download | freeipa.git-d9d196798945bef7a955acb8b71820800455be17.tar.gz freeipa.git-d9d196798945bef7a955acb8b71820800455be17.tar.xz freeipa.git-d9d196798945bef7a955acb8b71820800455be17.zip |
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.
Diffstat (limited to 'ipalib/encoder.py')
-rw-r--r-- | ipalib/encoder.py | 10 |
1 files changed, 9 insertions, 1 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) ) |