[repo] explicitly specifies edited attributes to glob_update_entity
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 03 Aug 2009 17:59:34 +0200
changeset 2667 c8aa82538d8e
parent 2666 c6c832d32936
child 2668 979c7ccb4a86
[repo] explicitly specifies edited attributes to glob_update_entity
server/repository.py
server/ssplanner.py
--- a/server/repository.py	Mon Aug 03 17:32:42 2009 +0200
+++ b/server/repository.py	Mon Aug 03 17:59:34 2009 +0200
@@ -1038,13 +1038,15 @@
                                     entity.eid, attr, value)
         return entity.eid
 
-    def glob_update_entity(self, session, entity):
+    def glob_update_entity(self, session, entity, edited_attributes):
         """replace an entity in the repository
         the type and the eid of an entity must not be changed
         """
         etype = str(entity.e_schema)
         if server.DEBUG & server.DBG_REPO:
-            print 'UPDATE entity', etype, entity.eid, dict(entity)
+            print 'UPDATE entity', etype, entity.eid, \
+                  dict(entity), edited_attributes
+        entity.edited_attributes = edited_attributes
         entity.check()
         eschema = entity.e_schema
         session.set_entity_cache(entity)
--- a/server/ssplanner.py	Mon Aug 03 17:32:42 2009 +0200
+++ b/server/ssplanner.py	Mon Aug 03 17:59:34 2009 +0200
@@ -482,6 +482,7 @@
         repo = session.repo
         edefs = {}
         # insert relations
+        attributes = [relation.r_type for relation in self.attribute_relations]
         for row in self.execute_child():
             for relation in self.attribute_relations:
                 lhs, rhs = relation.get_variable_parts()
@@ -489,7 +490,7 @@
                 try:
                     edef = edefs[eid]
                 except KeyError:
-                    edefs[eid] = edef = session.eid_rset(eid).get_entity(0, 0)
+                    edefs[eid] = edef = session.entity_from_eid(eid)
                 if isinstance(rhs, Constant):
                     # add constant values to entity def
                     value = rhs.eval(plan.args)
@@ -503,6 +504,6 @@
         # update entities
         result = []
         for eid, edef in edefs.iteritems():
-            repo.glob_update_entity(session, edef)
+            repo.glob_update_entity(session, edef, attributes)
             result.append( (eid,) )
         return result