119 rtype = self.rtype |
119 rtype = self.rtype |
120 if rtype in DONT_CHECK_RTYPES_ON_DEL: |
120 if rtype in DONT_CHECK_RTYPES_ON_DEL: |
121 return |
121 return |
122 session = self._cw |
122 session = self._cw |
123 eidfrom, eidto = self.eidfrom, self.eidto |
123 eidfrom, eidto = self.eidfrom, self.eidto |
124 pendingrdefs = session.transaction_data.get('pendingrdefs', ()) |
124 rdef = session.rtype_eids_rdef(rtype, eidfrom, eidto) |
125 if (session.describe(eidfrom)[0], rtype, session.describe(eidto)[0]) in pendingrdefs: |
125 if (rdef.subject, rtype, rdef.object) in session.transaction_data.get('pendingrdefs', ()): |
126 return |
126 return |
127 card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality') |
127 card = rdef.cardinality |
128 if card[0] in '1+' and not session.deleted_in_transaction(eidfrom): |
128 if card[0] in '1+' and not session.deleted_in_transaction(eidfrom): |
129 _CheckSRelationOp.get_instance(session).add_data((eidfrom, rtype)) |
129 _CheckSRelationOp.get_instance(session).add_data((eidfrom, rtype)) |
130 if card[1] in '1+' and not session.deleted_in_transaction(eidto): |
130 if card[1] in '1+' and not session.deleted_in_transaction(eidto): |
131 _CheckORelationOp.get_instance(session).add_data((eidto, rtype)) |
131 _CheckORelationOp.get_instance(session).add_data((eidto, rtype)) |
132 |
132 |
188 __regid__ = 'checkconstraint' |
188 __regid__ = 'checkconstraint' |
189 events = ('after_add_relation',) |
189 events = ('after_add_relation',) |
190 |
190 |
191 def __call__(self): |
191 def __call__(self): |
192 # XXX get only RQL[Unique]Constraints? |
192 # XXX get only RQL[Unique]Constraints? |
193 constraints = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
193 rdef = self._cw.rtype_eids_rdef(self.rtype, self.eidfrom, self.eidto) |
194 'constraints') |
194 constraints = rdef.constraints |
195 if constraints: |
195 if constraints: |
196 _CheckConstraintsOp.get_instance(self._cw).add_data( |
196 _CheckConstraintsOp.get_instance(self._cw).add_data( |
197 (self.eidfrom, self.rtype, self.eidto, constraints)) |
197 (self.eidfrom, self.rtype, self.eidto, constraints)) |
198 |
198 |
199 |
199 |
339 category = 'activeintegrity' |
339 category = 'activeintegrity' |
340 |
340 |
341 def __call__(self): |
341 def __call__(self): |
342 # if the relation is being delete, don't delete composite's components |
342 # if the relation is being delete, don't delete composite's components |
343 # automatically |
343 # automatically |
344 pendingrdefs = self._cw.transaction_data.get('pendingrdefs', ()) |
344 session = self._cw |
345 if (self._cw.describe(self.eidfrom)[0], self.rtype, |
345 rtype = self.rtype |
346 self._cw.describe(self.eidto)[0]) in pendingrdefs: |
346 rdef = session.rtype_eids_rdef(rtype, self.eidfrom, self.eidto) |
|
347 if (rdef.subject, rtype, rdef.object) in session.transaction_data.get('pendingrdefs', ()): |
347 return |
348 return |
348 composite = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
349 composite = rdef.composite |
349 'composite') |
|
350 if composite == 'subject': |
350 if composite == 'subject': |
351 _DelayedDeleteOEntityOp.get_instance(self._cw).add_data( |
351 _DelayedDeleteOEntityOp.get_instance(self._cw).add_data( |
352 (self.eidto, self.rtype)) |
352 (self.eidto, rtype)) |
353 elif composite == 'object': |
353 elif composite == 'object': |
354 _DelayedDeleteSEntityOp.get_instance(self._cw).add_data( |
354 _DelayedDeleteSEntityOp.get_instance(self._cw).add_data( |
355 (self.eidfrom, self.rtype)) |
355 (self.eidfrom, rtype)) |