# HG changeset patch # User Christophe de Vienne # Date 1422292018 -3600 # Node ID d92a608c1a16fb3dd23f01fd2801459ea58ac3d0 # Parent 444cd2bba89d77cb3411c51228bcfac4cd52eaba [core] Use tools.cached_user_build for better performances Closes #4870347 diff -r 444cd2bba89d -r d92a608c1a16 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: