diff -r e2c940c8c485 -r 851b6bd79b50 cubicweb/pyramid/tools.py --- a/cubicweb/pyramid/tools.py Thu Nov 10 18:23:45 2016 +0100 +++ b/cubicweb/pyramid/tools.py Thu Nov 10 18:25:50 2016 +0100 @@ -43,18 +43,12 @@ """Cached version of :meth:`cubicweb.server.repository.Repository._build_user` """ + if eid in _user_cache: + user, lang = _user_cache[eid] + entity = clone_user(repo, user) + return entity, lang + with repo.internal_cnx() as cnx: - if eid in _user_cache: - user, lang = _user_cache[eid] - entity = clone_user(repo, user) - # XXX the cnx is needed here so that the CWUser instance has an - # access to the vreg, which it needs when its 'prefered_language' - # property is accessed. - # If this property did not need a cnx to access a vreg, we could - # avoid the internal_cnx() and save more time. - cnx_attach_entity(cnx, entity) - return entity, lang - user = repo._build_user(cnx, eid) lang = user.prefered_language() user.cw_clear_relation_cache()