diff options
author | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-20 11:39:04 -0700 |
---|---|---|
committer | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-20 11:39:04 -0700 |
commit | c113d932b1a370cbf868447e32789a4f7c60bea2 (patch) | |
tree | 2959550c2ca8fba2a72e8e128fb8b8bef84e1d57 /ipa-python | |
parent | 66d3f1e730ed5e1bc80264b2a5d7f4fb16c1d22c (diff) | |
download | freeipa-c113d932b1a370cbf868447e32789a4f7c60bea2.tar.gz freeipa-c113d932b1a370cbf868447e32789a4f7c60bea2.tar.xz freeipa-c113d932b1a370cbf868447e32789a4f7c60bea2.zip |
Move utf-8 conversion inside user.py (for updates).
Diffstat (limited to 'ipa-python')
-rw-r--r-- | ipa-python/user.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ipa-python/user.py b/ipa-python/user.py index 38a634725..4377dad9b 100644 --- a/ipa-python/user.py +++ b/ipa-python/user.py @@ -3,6 +3,17 @@ import ldif import re import cStringIO +def utf8_encode_value(value): + if isinstance(value,unicode): + return value.encode('utf-8') + return value + +def utf8_encode_values(values): + if isinstance(values,list) or isinstance(values,tuple): + return map(utf8_encode_value, values) + else: + return utf8_encode_value(values) + class User: """This class represents an IPA user. An LDAP entry consists of a DN and a list of attributes. Each attribute consists of a name and a list of @@ -86,9 +97,9 @@ class User: if (len(value) < 1): return if (len(value) == 1): - self.data[name] = value[0] + self.data[name] = utf8_encode_values(value[0]) else: - self.data[name] = value + self.data[name] = utf8_encode_values(value) setValues = setValue |