set edited_attributes before call to pre_add_hook stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 07 Oct 2009 11:33:11 +0200
branchstable
changeset 3584 585c4423a54c
parent 3583 385d013c7adb
child 3585 cd437d24aa65
set edited_attributes before call to pre_add_hook
server/repository.py
--- a/server/repository.py	Wed Oct 07 11:32:54 2009 +0200
+++ b/server/repository.py	Wed Oct 07 11:33:11 2009 +0200
@@ -1005,6 +1005,9 @@
         the entity eid should originaly be None and a unique eid is assigned to
         the entity instance
         """
+        # init edited_attributes before calling before_add_entity hooks
+        entity._is_saved = False # entity has an eid but is not yet saved
+        entity.edited_attributes = set(entity)
         entity = entity.pre_add_hook()
         eschema = entity.e_schema
         etype = str(eschema)
@@ -1013,10 +1016,7 @@
         entity.set_eid(self.system_source.create_eid(session))
         if server.DEBUG & server.DBG_REPO:
             print 'ADD entity', etype, entity.eid, dict(entity)
-        entity._is_saved = False # entity has an eid but is not yet saved
         relations = []
-        # init edited_attributes before calling before_add_entity hooks
-        entity.edited_attributes = set(entity)
         if source.should_call_hooks:
             self.hm.call_hooks('before_add_entity', etype, session, entity)
         # XXX use entity.keys here since edited_attributes is not updated for