summaryrefslogtreecommitdiffstats
path: root/ipa-python
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-01-30 09:31:03 -0500
committerRob Crittenden <rcritten@redhat.com>2008-01-30 09:31:03 -0500
commitc50ebd965703acb666f3d368e32afe78e03630ce (patch)
tree637fb3aa1c303aedcc76db39767cb2452b5285c4 /ipa-python
parent97d9c235ddf5274836eb8bfc18e8798ae44614a0 (diff)
downloadfreeipa-c50ebd965703acb666f3d368e32afe78e03630ce.tar.gz
freeipa-c50ebd965703acb666f3d368e32afe78e03630ce.tar.xz
freeipa-c50ebd965703acb666f3d368e32afe78e03630ce.zip
Don't set blank values so we don't end up with empty attributes
Resolves 429895
Diffstat (limited to 'ipa-python')
-rw-r--r--ipa-python/entity.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/ipa-python/entity.py b/ipa-python/entity.py
index 81d2dd283..a5aa33ca3 100644
--- a/ipa-python/entity.py
+++ b/ipa-python/entity.py
@@ -122,6 +122,27 @@ class Entity:
setValues = setValue
+ def setValueNotEmpty(self,name,*value):
+ """Similar to setValue() but will not set an empty field. This
+ is an attempt to avoid adding empty attributes."""
+ if (len(value) >= 1) and value[0] and len(value[0]) > 0:
+ if isinstance(value[0], list):
+ if len(value[0][0]) > 0:
+ self.setValue(name, *value)
+ return
+ else:
+ self.setValue(name, *value)
+ return
+
+ # At this point we have an empty incoming value. See if they are
+ # trying to erase the current value. If so we'll delete it so
+ # it gets marked as removed in the modlist.
+ v = self.getValues(name)
+ if v:
+ self.delValue(name)
+
+ return
+
def delValue(self,name):
"""Remove the attribute named name."""
if self.data.get(name,None):