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.
This commit is contained in:
Jan Cholasta
2012-05-04 10:34:00 -04:00
committed by Martin Kosek
parent abef5e8c02
commit d9d1967989
7 changed files with 10 additions and 70 deletions

View File

@@ -59,7 +59,6 @@ except ImportError:
from ldap.functions import explode_dn
from ipalib.dn import DN
from ipalib import _
from ipalib.parameters import Bool
import krbV
@@ -76,23 +75,6 @@ MEMBERS_INDIRECT = 2
# SASL authentication mechanism
SASL_AUTH = _ldap_sasl.sasl({}, 'GSSAPI')
# OID 1.3.6.1.4.1.1466.115.121.1.7 (Boolean) syntax encoding
def _encode_bool(self, value):
def encode_bool_value(value):
if value is None:
return None
if value:
return u'TRUE'
return u'FALSE'
if type(value) in (tuple, list):
return tuple(encode_bool_value(v) for v in value)
else:
return encode_bool_value(value)
# set own Bool parameter encoder
Bool._encode = _encode_bool
class IPASimpleLDAPObject(SimpleLDAPObject):
'''
This is a thin layer over SimpleLDAPObject which allows us to utilize