228 """check the relation satisfy its constraints |
228 """check the relation satisfy its constraints |
229 |
229 |
230 this is delayed to a precommit time operation since other relation which |
230 this is delayed to a precommit time operation since other relation which |
231 will make constraint satisfied may be added later. |
231 will make constraint satisfied may be added later. |
232 """ |
232 """ |
|
233 if session.is_super_session: |
|
234 return |
233 constraints = rproperty(session, rtype, eidfrom, eidto, 'constraints') |
235 constraints = rproperty(session, rtype, eidfrom, eidto, 'constraints') |
234 if constraints: |
236 if constraints: |
235 CheckConstraintsOperation(session, constraints=constraints, |
237 CheckConstraintsOperation(session, constraints=constraints, |
236 rdef=(eidfrom, rtype, eidto)) |
238 rdef=(eidfrom, rtype, eidto)) |
237 |
239 |
238 def uniquecstrcheck_before_modification(session, entity): |
240 def uniquecstrcheck_before_modification(session, entity): |
|
241 if session.is_super_session: |
|
242 return |
239 eschema = entity.e_schema |
243 eschema = entity.e_schema |
240 for attr, val in entity.items(): |
244 for attr, val in entity.items(): |
241 if val is None: |
245 if val is None: |
242 continue |
246 continue |
243 if eschema.subject_relation(attr).is_final() and \ |
247 if eschema.subject_relation(attr).is_final() and \ |
247 if rset and rset[0][0] != entity.eid: |
251 if rset and rset[0][0] != entity.eid: |
248 msg = session._('the value "%s" is already used, use another one') |
252 msg = session._('the value "%s" is already used, use another one') |
249 raise ValidationError(entity.eid, {attr: msg % val}) |
253 raise ValidationError(entity.eid, {attr: msg % val}) |
250 |
254 |
251 def cstrcheck_after_update_attributes(session, entity): |
255 def cstrcheck_after_update_attributes(session, entity): |
|
256 if session.is_super_session: |
|
257 return |
252 schema = session.vreg.schema |
258 schema = session.vreg.schema |
253 for attr in entity.edited_attributes: |
259 for attr in entity.edited_attributes: |
254 if schema.rschema(attr).is_final(): |
260 if schema.rschema(attr).is_final(): |
255 constraints = [c for c in entity.e_schema.constraints(attr) |
261 constraints = [c for c in entity.e_schema.constraints(attr) |
256 if isinstance(c, RQLVocabularyConstraint)] |
262 if isinstance(c, RQLVocabularyConstraint)] |
304 opcls(session, rtype=rtype, eid=eid) |
310 opcls(session, rtype=rtype, eid=eid) |
305 |
311 |
306 |
312 |
307 def cardinalitycheck_after_add_entity(session, entity): |
313 def cardinalitycheck_after_add_entity(session, entity): |
308 """check cardinalities are satisfied""" |
314 """check cardinalities are satisfied""" |
|
315 if session.is_super_session: |
|
316 return |
309 eid = entity.eid |
317 eid = entity.eid |
310 for rschema, targetschemas, x in entity.e_schema.relation_definitions(): |
318 for rschema, targetschemas, x in entity.e_schema.relation_definitions(): |
311 # skip automatically handled relations |
319 # skip automatically handled relations |
312 if rschema.type in DONT_CHECK_RTYPES_ON_ADD: |
320 if rschema.type in DONT_CHECK_RTYPES_ON_ADD: |
313 continue |
321 continue |
325 if card[cardindex] in '1+': |
333 if card[cardindex] in '1+': |
326 checkrel_if_necessary(session, opcls, rschema.type, eid) |
334 checkrel_if_necessary(session, opcls, rschema.type, eid) |
327 |
335 |
328 def cardinalitycheck_before_del_relation(session, eidfrom, rtype, eidto): |
336 def cardinalitycheck_before_del_relation(session, eidfrom, rtype, eidto): |
329 """check cardinalities are satisfied""" |
337 """check cardinalities are satisfied""" |
|
338 if session.is_super_session: |
|
339 return |
330 if rtype in DONT_CHECK_RTYPES_ON_DEL: |
340 if rtype in DONT_CHECK_RTYPES_ON_DEL: |
331 return |
341 return |
332 card = rproperty(session, rtype, eidfrom, eidto, 'cardinality') |
342 card = rproperty(session, rtype, eidfrom, eidto, 'cardinality') |
333 pendingrdefs = session.transaction_data.get('pendingrdefs', ()) |
343 pendingrdefs = session.transaction_data.get('pendingrdefs', ()) |
334 if (session.describe(eidfrom)[0], rtype, session.describe(eidto)[0]) in pendingrdefs: |
344 if (session.describe(eidfrom)[0], rtype, session.describe(eidto)[0]) in pendingrdefs: |