hooks/integrity.py
changeset 3894 27cbf98ad863
parent 3890 d7a270f50f54
child 3998 94cc7cad3d2d
equal deleted inserted replaced
3890:d7a270f50f54 3894:27cbf98ad863
    91         eschema = self.entity.e_schema
    91         eschema = self.entity.e_schema
    92         for rschema, targetschemas, role in eschema.relation_definitions():
    92         for rschema, targetschemas, role in eschema.relation_definitions():
    93             # skip automatically handled relations
    93             # skip automatically handled relations
    94             if rschema.type in DONT_CHECK_RTYPES_ON_ADD:
    94             if rschema.type in DONT_CHECK_RTYPES_ON_ADD:
    95                 continue
    95                 continue
    96             if role == 'subject':
    96             opcls = role == 'subject' and _CheckSRelationOp or _CheckORelationOp
    97                 opcls = _CheckSRelationOp
       
    98             else:
       
    99                 opcls = _CheckORelationOp
       
   100             rdef = rschema.role_rdef(eschema, targetschemas[0], role)
    97             rdef = rschema.role_rdef(eschema, targetschemas[0], role)
   101             if rdef.role_cardinality(role) in '1+':
    98             if rdef.role_cardinality(role) in '1+':
   102                 self.checkrel_if_necessary(opcls, rschema.type, eid)
    99                 self.checkrel_if_necessary(opcls, rschema.type, eid)
   103 
   100 
   104     def before_delete_relation(self):
   101     def before_delete_relation(self):