server/repository.py
changeset 5726 c3b99606644d
parent 5655 ef903fff826d
child 5736 375819ec7d43
equal deleted inserted replaced
5725:b5d595b66c35 5726:c3b99606644d
   908         try:
   908         try:
   909             eid = self.system_source.create_eid(session)
   909             eid = self.system_source.create_eid(session)
   910             self._extid_cache[cachekey] = eid
   910             self._extid_cache[cachekey] = eid
   911             self._type_source_cache[eid] = (etype, source.uri, extid)
   911             self._type_source_cache[eid] = (etype, source.uri, extid)
   912             entity = source.before_entity_insertion(session, extid, etype, eid)
   912             entity = source.before_entity_insertion(session, extid, etype, eid)
   913             entity.edited_attributes = set(entity)
   913             entity.edited_attributes = set(entity.cw_attr_cache)
   914             if source.should_call_hooks:
   914             if source.should_call_hooks:
   915                 self.hm.call_hooks('before_add_entity', session, entity=entity)
   915                 self.hm.call_hooks('before_add_entity', session, entity=entity)
   916             # XXX call add_info with complete=False ?
   916             # XXX call add_info with complete=False ?
   917             self.add_info(session, entity, source, extid)
   917             self.add_info(session, entity, source, extid)
   918             source.after_entity_insertion(session, extid, entity)
   918             source.after_entity_insertion(session, extid, entity)
  1019         the entity eid should originaly be None and a unique eid is assigned to
  1019         the entity eid should originaly be None and a unique eid is assigned to
  1020         the entity instance
  1020         the entity instance
  1021         """
  1021         """
  1022         # init edited_attributes before calling before_add_entity hooks
  1022         # init edited_attributes before calling before_add_entity hooks
  1023         entity._cw_is_saved = False # entity has an eid but is not yet saved
  1023         entity._cw_is_saved = False # entity has an eid but is not yet saved
  1024         entity.edited_attributes = set(entity) # XXX cw_edited_attributes
  1024         entity.edited_attributes = set(entity.cw_attr_cache) # XXX cw_edited_attributes
  1025         eschema = entity.e_schema
  1025         eschema = entity.e_schema
  1026         source = self.locate_etype_source(entity.__regid__)
  1026         source = self.locate_etype_source(entity.__regid__)
  1027         # allocate an eid to the entity before calling hooks
  1027         # allocate an eid to the entity before calling hooks
  1028         entity.eid = self.system_source.create_eid(session)
  1028         entity.eid = self.system_source.create_eid(session)
  1029         # set caches asap
  1029         # set caches asap
  1034         if source.should_call_hooks:
  1034         if source.should_call_hooks:
  1035             self.hm.call_hooks('before_add_entity', session, entity=entity)
  1035             self.hm.call_hooks('before_add_entity', session, entity=entity)
  1036         # XXX use entity.keys here since edited_attributes is not updated for
  1036         # XXX use entity.keys here since edited_attributes is not updated for
  1037         # inline relations XXX not true, right? (see edited_attributes
  1037         # inline relations XXX not true, right? (see edited_attributes
  1038         # affectation above)
  1038         # affectation above)
  1039         for attr in entity.iterkeys():
  1039         for attr in entity.cw_attr_cache.iterkeys():
  1040             rschema = eschema.subjrels[attr]
  1040             rschema = eschema.subjrels[attr]
  1041             if not rschema.final: # inlined relation
  1041             if not rschema.final: # inlined relation
  1042                 relations.append((attr, entity[attr]))
  1042                 relations.append((attr, entity[attr]))
  1043         entity._cw_set_defaults()
  1043         entity._cw_set_defaults()
  1044         if session.is_hook_category_activated('integrity'):
  1044         if session.is_hook_category_activated('integrity'):