[session] Avoid deprecation warning on access to Connection.data 3.25
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 30 Mar 2017 11:56:09 +0200
branch3.25
changeset 12125 1d3a9bb46339
parent 12124 392d6d599286
child 12126 be8636d12afd
[session] Avoid deprecation warning on access to Connection.data this attribute has been deprecated during the session related rework, remove warning by explicitly storing data in .transaction_data since session data is not anymore reachable through Connection object. This will allows simplification of session synchronization hooks in a later cset. Also since we do not rely anymore on session data here, we may at some point rewrite those properties to rely on the ORM instead of such custom caching.
cubicweb/devtools/repotest.py
cubicweb/entities/authobjs.py
--- a/cubicweb/devtools/repotest.py	Thu Mar 30 10:43:49 2017 +0200
+++ b/cubicweb/devtools/repotest.py	Thu Mar 30 11:56:09 2017 +0200
@@ -251,7 +251,7 @@
         # use cnx.user.eid to get correct owned_by relation, unless explicit eid
         with self.admin_access.cnx() as cnx:
             user_eid = cnx.user.eid
-            cnx.user._cw.data[user_session_cache_key(user_eid, 'groups')] = set(groups)
+            cnx.user._cw.transaction_data[user_session_cache_key(user_eid, 'groups')] = set(groups)
             yield cnx
 
     def qexecute(self, rql, args=None, build_descr=True):
--- a/cubicweb/entities/authobjs.py	Thu Mar 30 10:43:49 2017 +0200
+++ b/cubicweb/entities/authobjs.py	Thu Mar 30 11:56:09 2017 +0200
@@ -62,26 +62,26 @@
     def groups(self):
         key = user_session_cache_key(self.eid, 'groups')
         try:
-            return self._cw.data[key]
+            return self._cw.transaction_data[key]
         except KeyError:
             with self._cw.security_enabled(read=False):
                 groups = set(group for group, in self._cw.execute(
                     'Any GN WHERE U in_group G, G name GN, U eid %(userid)s',
                     {'userid': self.eid}))
-            self._cw.data[key] = groups
+            self._cw.transaction_data[key] = groups
             return groups
 
     @property
     def properties(self):
         key = user_session_cache_key(self.eid, 'properties')
         try:
-            return self._cw.data[key]
+            return self._cw.transaction_data[key]
         except KeyError:
             with self._cw.security_enabled(read=False):
                 properties = dict(self._cw.execute(
                     'Any K, V WHERE P for_user U, U eid %(userid)s, '
                     'P pkey K, P value V', {'userid': self.eid}))
-            self._cw.data[key] = properties
+            self._cw.transaction_data[key] = properties
             return properties
 
     def prefered_language(self, language=None):