From 5f0f23ee91d51b2a45206ce7d9ddc413d3fa9670 Mon Sep 17 00:00:00 2001 From: "rcritten@redhat.com" Date: Tue, 14 Aug 2007 17:22:05 -0400 Subject: Ensure that the Apache server is in forked mode Add ability to update existing users Try to prevent fetching and setting empty strings --- ipa-python/user.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ipa-python/user.py') diff --git a/ipa-python/user.py b/ipa-python/user.py index 6162354b..3c925bfb 100644 --- a/ipa-python/user.py +++ b/ipa-python/user.py @@ -58,6 +58,8 @@ class User: def getValue(self,name): """Get the first value for the attribute named name""" value = self.data.get(name,[None]) + if (len(value) < 1): + return value if isinstance(value[0],list) or isinstance(value[0],tuple): return value[0] else: @@ -72,6 +74,8 @@ class User: ent.setValue('name', ('value1', 'value2', ..., 'valueN')) Since *value is a tuple, we may have to extract a list or tuple from that tuple as in the last two examples above""" + if (len(value[0]) < 1): + return if isinstance(value[0],list) or isinstance(value[0],tuple): self.data[name] = value[0] else: @@ -85,6 +89,15 @@ class User: single value or a list of values.""" return self.data.items() + 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['dn'] = self.dn + return result + def attrList(self): """Return a list of all attributes in the entry""" return self.data.keys() -- cgit