server/repository.py
branchstable
changeset 6189 9fa02f352c8c
parent 6188 e1c9610b2360
child 6211 e9d125fd1465
equal deleted inserted replaced
6188:e1c9610b2360 6189:9fa02f352c8c
    79     # same transaction where the entity is being created. This never occurs from
    79     # same transaction where the entity is being created. This never occurs from
    80     # the web interface but may occurs during test or dbapi connection (though
    80     # the web interface but may occurs during test or dbapi connection (though
    81     # not expected for this).  So: don't do it, we pretend to ensure repository
    81     # not expected for this).  So: don't do it, we pretend to ensure repository
    82     # consistency.
    82     # consistency.
    83     #
    83     #
    84     # XXX we don't want read permissions to be applied but we want delete
    84     # notes:
    85     # permission to be checked
    85     # * inlined relations will be implicitly deleted for the subject entity
    86     rschema = session.repo.schema.rschema(rtype)
    86     # * we don't want read permissions to be applied but we want delete
    87     if card[0] in '1?':
    87     #   permission to be checked
    88         if not rschema.inlined: # inlined relations will be implicitly deleted
    88     if card[0] in '1?' and not session.repo.schema.rschema(rtype).inlined:
    89             with security_enabled(session, read=False):
    89         with security_enabled(session, read=False):
    90                 session.execute('DELETE X %s Y WHERE X eid %%(x)s, '
    90             session.execute('DELETE X %s Y WHERE X eid %%(x)s, '
    91                                 'NOT Y eid %%(y)s' % rtype,
    91                             'NOT Y eid %%(y)s' % rtype,
    92                                 {'x': eidfrom, 'y': eidto})
    92                                 {'x': eidfrom, 'y': eidto})
    93     if card[1] in '1?':
    93     if card[1] in '1?':
    94         with security_enabled(session, read=False):
    94         with security_enabled(session, read=False):
    95             session.execute('DELETE X %s Y WHERE Y eid %%(y)s, '
    95             session.execute('DELETE X %s Y WHERE Y eid %%(y)s, '
    96                             'NOT X eid %%(x)s' % rtype,
    96                             'NOT X eid %%(x)s' % rtype,
  1078         for rschema in eschema.object_relations():
  1078         for rschema in eschema.object_relations():
  1079             rtype = str(rschema)
  1079             rtype = str(rschema)
  1080             if rtype in schema.VIRTUAL_RTYPES:
  1080             if rtype in schema.VIRTUAL_RTYPES:
  1081                 continue
  1081                 continue
  1082             entity.cw_set_relation_cache(rtype, 'object', session.empty_rset())
  1082             entity.cw_set_relation_cache(rtype, 'object', session.empty_rset())
  1083         # set inline relation cache before call to after_add_entity
  1083         # set inlined relation cache before call to after_add_entity
  1084         for attr, value in relations:
  1084         for attr, value in relations:
  1085             session.update_rel_cache_add(entity.eid, attr, value)
  1085             session.update_rel_cache_add(entity.eid, attr, value)
  1086             del_existing_rel_if_needed(session, entity.eid, attr, value)
  1086             del_existing_rel_if_needed(session, entity.eid, attr, value)
  1087         # trigger after_add_entity after after_add_relation
  1087         # trigger after_add_entity after after_add_relation
  1088         if source.should_call_hooks:
  1088         if source.should_call_hooks: