30 """ |
30 """ |
31 |
31 |
32 def __init__(self, session, *args, **kw): |
32 def __init__(self, session, *args, **kw): |
33 super(Connection, self).__init__(session, *args, **kw) |
33 super(Connection, self).__init__(session, *args, **kw) |
34 self._session = session |
34 self._session = session |
|
35 self.lang = session._cached_lang |
35 |
36 |
36 def _get_session_data(self): |
37 def _get_session_data(self): |
37 return self._session.data |
38 return self._session.data |
38 |
39 |
39 def _set_session_data(self, data): |
40 def _set_session_data(self, data): |
270 |
271 |
271 def repo_connect(request, repo, eid): |
272 def repo_connect(request, repo, eid): |
272 """A lightweight version of |
273 """A lightweight version of |
273 :meth:`cubicweb.server.repository.Repository.connect` that does not keep |
274 :meth:`cubicweb.server.repository.Repository.connect` that does not keep |
274 track of opened sessions, removing the need of closing them""" |
275 track of opened sessions, removing the need of closing them""" |
275 user = tools.cached_build_user(repo, eid) |
276 user, lang = tools.cached_build_user(repo, eid) |
276 session = Session(request, user, repo) |
277 session = Session(request, user, repo) |
|
278 session._cached_lang = lang |
277 tools.cnx_attach_entity(session, user) |
279 tools.cnx_attach_entity(session, user) |
278 # Calling the hooks should be done only once, disabling it completely for |
280 # Calling the hooks should be done only once, disabling it completely for |
279 # now |
281 # now |
280 # with session.new_cnx() as cnx: |
282 # with session.new_cnx() as cnx: |
281 # repo.hm.call_hooks('session_open', cnx) |
283 # repo.hm.call_hooks('session_open', cnx) |