server/repository.py
changeset 4834 b718626a0e60
parent 4808 23df4a120c96
child 4835 13b0b96d7982
equal deleted inserted replaced
4833:41a78fb4107c 4834:b718626a0e60
    83     # XXX now that rql in migraction default to unsafe_execute we don't want to
    83     # XXX now that rql in migraction default to unsafe_execute we don't want to
    84     #     skip that for super session (though we can still skip it for internal
    84     #     skip that for super session (though we can still skip it for internal
    85     #     sessions). Also we should imo rely on the orm to first fetch existing
    85     #     sessions). Also we should imo rely on the orm to first fetch existing
    86     #     entity if any then delete it.
    86     #     entity if any then delete it.
    87     if session.is_internal_session \
    87     if session.is_internal_session \
    88            or not session.vreg.config.is_hook_category_activated('integrity'):
    88            or not session.is_hooks_category_activated('integrity'):
    89         return
    89         return
    90     card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality')
    90     card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality')
    91     # one may be tented to check for neweids but this may cause more than one
    91     # one may be tented to check for neweids but this may cause more than one
    92     # relation even with '1?'  cardinality if thoses relations are added in the
    92     # relation even with '1?'  cardinality if thoses relations are added in the
    93     # same transaction where the entity is being created. This never occurs from
    93     # same transaction where the entity is being created. This never occurs from
   986         for attr in entity.keys():
   986         for attr in entity.keys():
   987             rschema = eschema.subjrels[attr]
   987             rschema = eschema.subjrels[attr]
   988             if not rschema.final: # inlined relation
   988             if not rschema.final: # inlined relation
   989                 relations.append((attr, entity[attr]))
   989                 relations.append((attr, entity[attr]))
   990         entity.set_defaults()
   990         entity.set_defaults()
   991         entity.check(creation=True)
   991         if session.is_hooks_category_activated('integrity'):
       
   992             entity.check(creation=True)
   992         source.add_entity(session, entity)
   993         source.add_entity(session, entity)
   993         if source.uri != 'system':
   994         if source.uri != 'system':
   994             extid = source.get_extid(entity)
   995             extid = source.get_extid(entity)
   995             self._extid_cache[(str(extid), source.uri)] = entity.eid
   996             self._extid_cache[(str(extid), source.uri)] = entity.eid
   996         else:
   997         else:
  1033         etype = str(entity.e_schema)
  1034         etype = str(entity.e_schema)
  1034         if server.DEBUG & server.DBG_REPO:
  1035         if server.DEBUG & server.DBG_REPO:
  1035             print 'UPDATE entity', etype, entity.eid, \
  1036             print 'UPDATE entity', etype, entity.eid, \
  1036                   dict(entity), edited_attributes
  1037                   dict(entity), edited_attributes
  1037         entity.edited_attributes = edited_attributes
  1038         entity.edited_attributes = edited_attributes
  1038         entity.check()
  1039         if session.is_hooks_category_activated('integrity'):
       
  1040             entity.check()
  1039         eschema = entity.e_schema
  1041         eschema = entity.e_schema
  1040         session.set_entity_cache(entity)
  1042         session.set_entity_cache(entity)
  1041         only_inline_rels, need_fti_update = True, False
  1043         only_inline_rels, need_fti_update = True, False
  1042         relations = []
  1044         relations = []
  1043         for attr in edited_attributes:
  1045         for attr in edited_attributes: