[entity edition] don't remove values from attribute cache on the repository side
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Aug 2012 13:29:37 +0200
changeset 8525 c09feae04094
parent 8513 552de9f0c46d
child 8535 268b6349baf3
[entity edition] don't remove values from attribute cache on the repository side This follows changesets 552de9f0c46d, 1527b012802f, 25da1e5c7c50 and 4ba11607d84a. closes #2423719 ?
entity.py
req.py
server/session.py
--- a/entity.py	Thu Aug 02 19:00:22 2012 +0200
+++ b/entity.py	Fri Aug 03 13:29:37 2012 +0200
@@ -559,10 +559,14 @@
         raise NotImplementedError('comparison not implemented for %s' % self.__class__)
 
     def _cw_update_attr_cache(self, attrcache):
-        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)
+        # if context is a repository session, don't consider dont-cache-attrs as
+        # the instance already hold modified values and loosing them could
+        # introduce severe problems
+        if self._cw.is_request:
+            for attr in self._cw.get_shared_data('%s.dont-cache-attrs' % self.eid,
+                                                 default=(), txdata=True, pop=True):
+                attrcache.pop(attr, None)
+                self.cw_attr_cache.pop(attr, None)
         self.cw_attr_cache.update(attrcache)
 
     def _cw_dont_cache_attribute(self, attr):
--- a/req.py	Thu Aug 02 19:00:22 2012 +0200
+++ b/req.py	Fri Aug 03 13:29:37 2012 +0200
@@ -62,6 +62,8 @@
     :attribute vreg.schema: the instance's schema
     :attribute vreg.config: the instance's configuration
     """
+    is_request = True # False for repository session
+
     def __init__(self, vreg):
         self.vreg = vreg
         try:
--- a/server/session.py	Thu Aug 02 19:00:22 2012 +0200
+++ b/server/session.py	Fri Aug 03 13:29:37 2012 +0200
@@ -241,6 +241,7 @@
       :attr:`running_dbapi_query`, boolean flag telling if the executing query
       is coming from a dbapi connection or is a query from within the repository
     """
+    is_request = False
     is_internal_session = False
 
     def __init__(self, user, repo, cnxprops=None, _id=None):