diff options
author | Simo Sorce <ssorce@redhat.com> | 2007-08-28 10:46:03 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2007-08-28 10:46:03 -0400 |
commit | 46eeca740ee4d66bfd4f062896220dfb5527f5b6 (patch) | |
tree | b5a91cf249e823ddb9ab01e9797c742caa90de50 /ipa-python/entity.py | |
parent | 4702eb907585556d83b3373bf06705d83ae3ed2d (diff) | |
parent | 6eea6664e079d187c3b0420b4283af35205d3b03 (diff) | |
download | freeipa.git-46eeca740ee4d66bfd4f062896220dfb5527f5b6.tar.gz freeipa.git-46eeca740ee4d66bfd4f062896220dfb5527f5b6.tar.xz freeipa.git-46eeca740ee4d66bfd4f062896220dfb5527f5b6.zip |
Merge in with upstream
Diffstat (limited to 'ipa-python/entity.py')
-rw-r--r-- | ipa-python/entity.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ipa-python/entity.py b/ipa-python/entity.py index 9153c415..2f0629cd 100644 --- a/ipa-python/entity.py +++ b/ipa-python/entity.py @@ -3,6 +3,8 @@ import ldif import re import cStringIO +import ipa.ipautil + def utf8_encode_value(value): if isinstance(value,unicode): return value.encode('utf-8') @@ -22,8 +24,8 @@ class Entity: In python-ldap, entries are returned as a list of 2-tuples. Instance variables: dn - string - the string DN of the entry - data - cidict - case insensitive dict of the attributes and values - orig_data - cidict - case insentiive dict of the original attributes and values""" + data - CIDict - case insensitive dict of the attributes and values + orig_data - CIDict - case insentiive dict of the original attributes and values""" def __init__(self,entrydata=None): """data is the raw data returned from the python-ldap result method, @@ -32,19 +34,19 @@ class Entity: if entrydata: if isinstance(entrydata,tuple): self.dn = entrydata[0] - self.data = ldap.cidict.cidict(entrydata[1]) + self.data = ipa.ipautil.CIDict(entrydata[1]) elif isinstance(entrydata,str) or isinstance(entrydata,unicode): self.dn = entrydata - self.data = ldap.cidict.cidict() + self.data = ipa.ipautil.CIDict() elif isinstance(entrydata,dict): self.dn = entrydata['dn'] del entrydata['dn'] - self.data = ldap.cidict.cidict(entrydata) + self.data = ipa.ipautil.CIDict(entrydata) else: self.dn = '' - self.data = ldap.cidict.cidict() + self.data = ipa.ipautil.CIDict() - self.orig_data = dict(self.data) + self.orig_data = ipa.ipautil.CIDict(self.data) def __nonzero__(self): """This allows us to do tests like if entry: returns false if there is no data, @@ -112,9 +114,7 @@ class Entity: def toDict(self): """Convert the attrs and values to a dict. The dict is keyed on the attribute name. The value is either single value or a list of values.""" - result = {} - for k in self.data.keys(): - result[k] = self.data[k] + result = ipa.ipautil.CIDict(self.data) result['dn'] = self.dn return result @@ -124,9 +124,7 @@ class Entity: def origDataDict(self): """Returns a dict of the original values of the user. Used for updates.""" - result = {} - for k in self.orig_data.keys(): - result[k] = self.orig_data[k] + result = ipa.ipautil.CIDict(self.orig_data) result['dn'] = self.dn return result |