[core] Use tools.cached_user_build for better performances
authorChristophe de Vienne <christophe@unlish.com>
Mon, 26 Jan 2015 18:06:58 +0100
changeset 11552 d92a608c1a16
parent 11551 444cd2bba89d
child 11553 a322a02ca301
[core] Use tools.cached_user_build for better performances Closes #4870347
pyramid_cubicweb/core.py
--- a/pyramid_cubicweb/core.py	Mon Jan 26 18:04:57 2015 +0100
+++ b/pyramid_cubicweb/core.py	Mon Jan 26 18:06:58 2015 +0100
@@ -13,7 +13,7 @@
 
 from pyramid import httpexceptions
 
-from pyramid_cubicweb import authplugin
+from pyramid_cubicweb import authplugin, tools
 
 import logging
 
@@ -179,11 +179,9 @@
     """A lightweight version of
     :meth:`cubicweb.server.repository.Repository.connect` that does not keep
     track of opened sessions, removing the need of closing them"""
-    with repo.internal_cnx() as cnx:
-        user = repo._build_user(cnx, eid=eid)
+    user = tools.cached_build_user(repo, eid)
     session = Session(user, repo, None)
-    user._cw = user.cw_rset.req = session
-    user.cw_clear_relation_cache()
+    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: