147 if role == 'subject': |
147 if role == 'subject': |
148 op = _CheckSRelationOp.get_instance(self._cw) |
148 op = _CheckSRelationOp.get_instance(self._cw) |
149 else: |
149 else: |
150 op = _CheckORelationOp.get_instance(self._cw) |
150 op = _CheckORelationOp.get_instance(self._cw) |
151 op.add_data((eid, rschema.type)) |
151 op.add_data((eid, rschema.type)) |
152 |
|
153 def before_delete_relation(self): |
|
154 rtype = self.rtype |
|
155 if rtype in DONT_CHECK_RTYPES_ON_DEL: |
|
156 return |
|
157 session = self._cw |
|
158 eidfrom, eidto = self.eidfrom, self.eidto |
|
159 pendingrdefs = session.transaction_data.get('pendingrdefs', ()) |
|
160 if (session.describe(eidfrom)[0], rtype, session.describe(eidto)[0]) in pendingrdefs: |
|
161 return |
|
162 card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality') |
|
163 if card[0] in '1+' and not session.deleted_in_transaction(eidfrom): |
|
164 _CheckSRelationOp.get_instance(self._cw).add_data((eidfrom, rtype)) |
|
165 if card[1] in '1+' and not session.deleted_in_transaction(eidto): |
|
166 _CheckORelationOp.get_instance(self._cw).add_data((eidto, rtype)) |
|
167 |
152 |
168 |
153 |
169 class _CheckConstraintsOp(hook.DataOperationMixIn, hook.LateOperation): |
154 class _CheckConstraintsOp(hook.DataOperationMixIn, hook.LateOperation): |
170 """ check a new relation satisfy its constraints """ |
155 """ check a new relation satisfy its constraints """ |
171 containercls = list |
156 containercls = list |