From f88b6ec688effdde94d15b8d35d924de6bd9ded1 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 10 Apr 2013 10:53:23 +0200 Subject: [PATCH] =?UTF-8?q?[lc=5Fldap]=20Il=20arrive=20d'ajouter=20des=20a?= =?UTF-8?q?ttributs=20=C3=A0=20un=20objets=20qui=20n'existe=20pas=20encore?= =?UTF-8?q?,=20par=20exemple=20pour=20les=20attributs=20optionnels,=20il?= =?UTF-8?q?=20faut=20voir=20ce=20que=20=C3=A7a=20implique=20vis=20=C3=A7?= =?UTF-8?q?=20vis=20du=20test=20d'unicit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lc_ldap.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lc_ldap.py b/lc_ldap.py index 1cd8c84..4320ee1 100644 --- a/lc_ldap.py +++ b/lc_ldap.py @@ -634,11 +634,14 @@ class CransLdapObject(object): # faire le changement que si on peut) attrs_before_verif = [ attributs.attrify(val, attr, self.conn, Parent=self) for val in values ] - for attribut in attrs_before_verif: - attribut.check_uniqueness([str(content) for content in self.attrs[attr]]) + if attr in self.attrs.keys(): + for attribut in attrs_before_verif: + attribut.check_uniqueness([str(content) for content in self.attrs[attr]]) - # On groupe les attributs précédents, et les nouveaux - mixed_attrs = attrs_before_verif + self.attrs[attr] + # On groupe les attributs précédents, et les nouveaux + mixed_attrs = attrs_before_verif + self.attrs[attr] + else: + mixed_attrs = attrs_before_verif # Si c'est vide, on fait pas de vérifs, on avait une liste # vide avant, puis on en a une nouvelle après. if mixed_attrs: