diff options
author | Rob Crittenden <rcritten@redhat.com> | 2008-01-30 09:31:03 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2008-01-30 09:31:03 -0500 |
commit | c50ebd965703acb666f3d368e32afe78e03630ce (patch) | |
tree | 637fb3aa1c303aedcc76db39767cb2452b5285c4 /ipa-python | |
parent | 97d9c235ddf5274836eb8bfc18e8798ae44614a0 (diff) | |
download | freeipa-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.py | 21 |
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): |