[entity] more tweaks for entity attribute cache handling on cw_set/cw_create to fix test regression
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 24 Jul 2012 11:19:16 +0200
changeset 8494 1527b012802f
parent 8493 25da1e5c7c50
child 8495 0bc63e46bdb5
[entity] more tweaks for entity attribute cache handling on cw_set/cw_create to fix test regression * when an attribute is listed in dont-cache-attrs, purge any previous value * test value is actually modified in EditedEntity.__setitem__ before adding attribute to dont-cache-attrs
entity.py
server/edition.py
--- a/entity.py	Tue Jul 24 10:16:25 2012 +0200
+++ b/entity.py	Tue Jul 24 11:19:16 2012 +0200
@@ -562,6 +562,7 @@
         for key in self._cw.get_shared_data('%s.dont-cache-attrs' % self.eid,
                                             default=(), txdata=True, pop=True):
             attrcache.pop(key, None)
+            self.cw_attr_cache.pop(key, None)
         self.cw_attr_cache.update(attrcache)
 
     def _cw_dont_cache_attribute(self, attr):
--- a/server/edition.py	Tue Jul 24 10:16:25 2012 +0200
+++ b/server/edition.py	Tue Jul 24 11:19:16 2012 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -61,7 +61,10 @@
         # attributes, else we may accidentaly skip a desired security check
         if attr not in self:
             self.skip_security.add(attr)
-        self.entity._cw_dont_cache_attribute(attr)
+        elif value != self[attr]:
+            # also, if value differs, mark attribute as needing purge by the
+            # client
+            self.entity._cw_dont_cache_attribute(attr)
         self.edited_attribute(attr, value)
 
     def __delitem__(self, attr):