summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-12-08 13:26:27 -0500
committerRob Crittenden <rcritten@redhat.com>2010-12-10 13:42:47 -0500
commite8e274c9e0a9fb9d2ef775f99c763d97b23050b1 (patch)
tree74ce17aa1891f94c9d41d7c32e9bb70851964e74 /ipalib/frontend.py
parent1a20d754216bafb82aa40ea584c7de7c9a5b0b07 (diff)
downloadfreeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.tar.gz
freeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.tar.xz
freeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.zip
Properly handle multi-valued attributes when using setattr/addattr.
The problem was that the normalizer was returning each value as a tuple which we were then appending to a list, so it looked like [(u'value1',), (u'value2',),...]. If there was a single value we could end up adding a tuple to a list which would fail. Additionally python-ldap doesn't like lists of lists so it was failing later in the process as well. I've added some simple tests for setattr and addattr. ticket 565
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index ac1f67ee1..6be50ba52 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -538,9 +538,15 @@ class Command(HasParam):
if attr in self.params:
value = self.params[attr](value)
if append and attr in newdict:
- newdict[attr].append(value)
+ if type(value) in (tuple,):
+ newdict[attr] += list(value)
+ else:
+ newdict[attr].append(value)
else:
- newdict[attr] = [value]
+ if type(value) in (tuple,):
+ newdict[attr] = list(value)
+ else:
+ newdict[attr] = [value]
return newdict
def __attributes_2_entry(self, kw):