summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-08-13 16:20:41 -0400
committerAdam Young <ayoung@redhat.com>2010-08-13 16:20:41 -0400
commit030b5dab93971495d8656f7886c29136e118a9e6 (patch)
treecb3bf3ca3fed61c777bedb713054954bbfb2abeb /ipalib/frontend.py
parentf15758dbea6be0894cdc2fcc19ec9d2428c797f1 (diff)
downloadfreeipa-030b5dab93971495d8656f7886c29136e118a9e6.tar.gz
freeipa-030b5dab93971495d8656f7886c29136e118a9e6.tar.xz
freeipa-030b5dab93971495d8656f7886c29136e118a9e6.zip
Change the behaviour of addattr/setattr parameters.
setattr and addattr can now be used both to set all values of ANY attribute. the last setattr always resets the attribute to the specified value and all addattr append to it. Examples: user-mod testuser --setattr=title=msc title: msc user-mod testuser --setattr=title=msb title: msb user-mod testuser --addattr=title=msc title: msb, msc user-mod testuser --setattr=title= title: user-mod testuser --setattr=title=msc --addattr=msb title: msc, msb user-mod testuser --setattr=title=ing --addattr=bc title: ing, bc user-mod testuser --setattr=title=doc title: doc It's not very user friendly, but it's going to be used very very rarely in special conditions in the CLI and we can use it to save lots of JSON-RPC roundtrips in the webUI. This version includes calling the validation of Params during the setting of the attrs.
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index d320f02e..1c4fea8c 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -519,11 +519,12 @@ class Command(HasParam):
if len(value) == 0:
# None means "delete this attribute"
value = None
- if attr not in self.params:
- if append and attr in newdict:
- newdict[attr].append(value)
- else:
- newdict[attr] = [value]
+ if attr in self.params:
+ value = self.params[attr](value)
+ if append and attr in newdict:
+ newdict[attr].append(value)
+ else:
+ newdict[attr] = [value]
return newdict
def __attributes_2_entry(self, kw):
@@ -540,7 +541,11 @@ class Command(HasParam):
adddict = self.__convert_2_dict(kw['setattr'], append=False)
if kw.get('addattr'):
- adddict.update(self.__convert_2_dict(kw['addattr']))
+ for (k, v) in self.__convert_2_dict(kw['addattr']).iteritems():
+ if k in adddict:
+ adddict[k] += v
+ else:
+ adddict[k] = v
for name in adddict:
value = adddict[name]