towards better edited attributes handling stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 17 Aug 2009 12:11:54 +0200
branchstable
changeset 2875 b7399ef8b3e0
parent 2874 acdd8d8c2cff
child 2876 b6993462ddb9
towards better edited attributes handling
entity.py
server/repository.py
server/ssplanner.py
--- a/entity.py	Mon Aug 17 12:11:04 2009 +0200
+++ b/entity.py	Mon Aug 17 12:11:54 2009 +0200
@@ -944,11 +944,9 @@
         return eobj.get_value(self._attrname)
 
     def __set__(self, eobj, value):
-        # XXX bw compat
-        # would be better to generate UPDATE queries than the current behaviour
-        eobj.warning("deprecated usage, don't use 'entity.attr = val' notation)")
         eobj[self._attrname] = value
-
+        if hasattr(eobj, 'edited_attributes'):
+            eobj.edited_attributes.add(self._attrname)
 
 class Relation(object):
     """descriptor that controls schema relation access"""
--- a/server/repository.py	Mon Aug 17 12:11:04 2009 +0200
+++ b/server/repository.py	Mon Aug 17 12:11:54 2009 +0200
@@ -1004,7 +1004,7 @@
                 relations.append((attr, entity[attr]))
         if source.should_call_hooks:
             self.hm.call_hooks('before_add_entity', etype, session, entity)
-        entity.edited_attributes = entity.keys()
+        entity.edited_attributes = set(entity)
         entity.set_defaults()
         entity.check(creation=True)
         source.add_entity(session, entity)
--- a/server/ssplanner.py	Mon Aug 17 12:11:04 2009 +0200
+++ b/server/ssplanner.py	Mon Aug 17 12:11:54 2009 +0200
@@ -482,7 +482,7 @@
         repo = session.repo
         edefs = {}
         # insert relations
-        attributes = [relation.r_type for relation in self.attribute_relations]
+        attributes = set([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()