[objets.__setitem__] On libère les locks des valeurs que l'on oublie
This commit is contained in:
parent
1312039a55
commit
ac0445b7e3
1 changed files with 23 additions and 7 deletions
30
objets.py
30
objets.py
|
@ -518,14 +518,30 @@ class CransLdapObject(object):
|
||||||
# Tests de droits.
|
# Tests de droits.
|
||||||
if not mixed_attrs[0].is_modifiable(self.conn.droits + self.conn._check_parent(self.dn) + self.conn._check_self(self.dn)):
|
if not mixed_attrs[0].is_modifiable(self.conn.droits + self.conn._check_parent(self.dn) + self.conn._check_self(self.dn)):
|
||||||
raise EnvironmentError("Vous ne pouvez pas toucher aux attributs de type %r." % (attr))
|
raise EnvironmentError("Vous ne pouvez pas toucher aux attributs de type %r." % (attr))
|
||||||
self._modifs[attr] = attrs_before_verif
|
|
||||||
for attribut in attrs_before_verif:
|
|
||||||
if attribut.unique:
|
# On ajoute des locks sur les nouvelles valeurs
|
||||||
try:
|
locked = []
|
||||||
|
try:
|
||||||
|
for attribut in attrs_before_verif:
|
||||||
|
if attribut.unique and not attribut in self._modifs.get(attr, []):
|
||||||
self.conn.lockholder.addlock(attr, str(attribut), self.lockId)
|
self.conn.lockholder.addlock(attr, str(attribut), self.lockId)
|
||||||
except:
|
locked.append((attr, str(attribut), self.lockId))
|
||||||
self._modifs[attr] = list(self.attrs[attr])
|
except ldap_locks.LockError:
|
||||||
raise
|
# Si on ne parvient pas à prendre le lock pour l'une des valeurs
|
||||||
|
# on libère les locks pris jusque là et on propage l'erreur
|
||||||
|
# les anciens locks et self._modifs reste bien inchangés
|
||||||
|
for (a, b, c) in locked:
|
||||||
|
self.conn.lockholder.removelock(a, b, c)
|
||||||
|
raise
|
||||||
|
|
||||||
|
# On retire les locks des attributs que l'on ne va plus utiliser
|
||||||
|
for attribut in self._modifs.get(attr, []):
|
||||||
|
if attribut.unique and not attribut in attrs_before_verif:
|
||||||
|
self.conn.lockholder.removelock(attr, str(attribut), self.lockId)
|
||||||
|
|
||||||
|
# On met à jour self._modifs avec les nouvelles valeurs
|
||||||
|
self._modifs[attr] = attrs_before_verif
|
||||||
|
|
||||||
def search_historique(self, ign_fields=HIST_IGNORE_FIELDS):
|
def search_historique(self, ign_fields=HIST_IGNORE_FIELDS):
|
||||||
u"""Récupère l'historique
|
u"""Récupère l'historique
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue