cubicweb/pyramid/core.py
changeset 11841 48adf4dd1ce6
parent 11824 d7ecf6dab085
child 11913 4516c3956d46
child 11925 b75fc687c730
--- a/cubicweb/pyramid/core.py	Thu Nov 17 11:00:01 2016 +0100
+++ b/cubicweb/pyramid/core.py	Fri Nov 18 15:42:10 2016 +0100
@@ -7,7 +7,6 @@
 import rql
 
 from cubicweb.web.request import CubicWebRequestBase
-from cubicweb import repoapi
 
 import cubicweb
 import cubicweb.web
@@ -29,9 +28,11 @@
     This behavior makes sure the actual session data is not loaded until
     actually accessed.
     """
+
     def __init__(self, session, *args, **kw):
         super(Connection, self).__init__(session, *args, **kw)
         self._session = session
+        self.lang = session._cached_lang
 
     def _get_session_data(self):
         return self._session.data
@@ -272,14 +273,15 @@
     """A lightweight version of
     :meth:`cubicweb.server.repository.Repository.connect` that does not keep
     track of opened sessions, removing the need of closing them"""
-    user = tools.cached_build_user(repo, eid)
+    user, lang = tools.cached_build_user(repo, eid)
     session = Session(request, user, repo)
+    session._cached_lang = lang
     tools.cnx_attach_entity(session, user)
     # Calling the hooks should be done only once, disabling it completely for
     # now
-    #with session.new_cnx() as cnx:
-        #repo.hm.call_hooks('session_open', cnx)
-        #cnx.commit()
+    # with session.new_cnx() as cnx:
+    #     repo.hm.call_hooks('session_open', cnx)
+    #     cnx.commit()
     # repo._sessions[session.sessionid] = session
     return session