[objets] En cas d'ajout de lock hors contexte, on affiche un warning

This commit is contained in:
Valentin Samir 2014-02-26 10:27:48 +01:00
parent 06ea17715b
commit d8b1e5da51

View file

@ -533,6 +533,8 @@ class CransLdapObject(object):
try: try:
for attribut in attrs_before_verif: for attribut in attrs_before_verif:
if attribut.unique and not attribut in self._modifs.get(attr, []): if attribut.unique and not attribut in self._modifs.get(attr, []):
if not self.in_context:
cranslib.deprecated.usage("Des locks ne devrait être ajoutés que dans un context manager", level=2)
self.conn.lockholder.addlock(attr, str(attribut), self.lockId) self.conn.lockholder.addlock(attr, str(attribut), self.lockId)
locked.append((attr, str(attribut), self.lockId)) locked.append((attr, str(attribut), self.lockId))
except ldap_locks.LockError: except ldap_locks.LockError: