fix bug with damned transmutation functionality, occuring when using an INSERT query which also add relation to the entity stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 23 Mar 2010 17:06:05 +0100
branchstable
changeset 4973 1e6536afa855
parent 4972 7b0cd6e024e2
child 4974 025a491bad0c
fix bug with damned transmutation functionality, occuring when using an INSERT query which also add relation to the entity
server/repository.py
--- a/server/repository.py	Tue Mar 23 17:05:05 2010 +0100
+++ b/server/repository.py	Tue Mar 23 17:06:05 2010 +0100
@@ -975,7 +975,11 @@
         # 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()
+        entity_ = entity.pre_add_hook()
+        # XXX kill that transmutation feature !
+        if not entity_ is entity:
+            entity.__class__ = entity_.__class__
+            entity.__dict__.update(entity_.__dict__)
         eschema = entity.e_schema
         etype = str(eschema)
         source = self.locate_etype_source(etype)