backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 10 Jun 2011 17:41:41 +0200
changeset 7496 0c75ed374b06
parent 7493 3c46b9390871 (current diff)
parent 7495 09d245a9bf5f (diff)
child 7497 7beb71d76d82
backport stable
--- a/hooks/integrity.py	Fri Jun 10 16:54:20 2011 +0200
+++ b/hooks/integrity.py	Fri Jun 10 17:41:41 2011 +0200
@@ -126,9 +126,10 @@
             return
         card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality')
         if card[0] in '1+' and not session.deleted_in_transaction(eidfrom):
-            _CheckSRelationOp.get_instance(self._cw).add_data((eidfrom, rtype))
+            _CheckSRelationOp.get_instance(session).add_data((eidfrom, rtype))
         if card[1] in '1+' and not session.deleted_in_transaction(eidto):
-            _CheckORelationOp.get_instance(self._cw).add_data((eidto, rtype))
+            _CheckORelationOp.get_instance(session).add_data((eidto, rtype))
+
 
 class CheckCardinalityHookAfterAddEntity(IntegrityHook):
     """check cardinalities are satisfied"""
@@ -150,21 +151,6 @@
                     op = _CheckORelationOp.get_instance(self._cw)
                 op.add_data((eid, rschema.type))
 
-    def before_delete_relation(self):
-        rtype = self.rtype
-        if rtype in DONT_CHECK_RTYPES_ON_DEL:
-            return
-        session = self._cw
-        eidfrom, eidto = self.eidfrom, self.eidto
-        pendingrdefs = session.transaction_data.get('pendingrdefs', ())
-        if (session.describe(eidfrom)[0], rtype, session.describe(eidto)[0]) in pendingrdefs:
-            return
-        card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality')
-        if card[0] in '1+' and not session.deleted_in_transaction(eidfrom):
-            _CheckSRelationOp.get_instance(self._cw).add_data((eidfrom, rtype))
-        if card[1] in '1+' and not session.deleted_in_transaction(eidto):
-            _CheckORelationOp.get_instance(self._cw).add_data((eidto, rtype))
-
 
 class _CheckConstraintsOp(hook.DataOperationMixIn, hook.LateOperation):
     """ check a new relation satisfy its constraints """