# HG changeset patch # User Sylvain Thénault # Date 1465220221 -7200 # Node ID ca536eec556b4a58ba7fceed28b1a45528497202 # Parent 41ddaf6802f02b6d4c2d8c5e9765f5d1e9761ad0 [pyramid] Retrieve user's groups using a custom RQL instead of user's groups property With cubicweb 3.24, user.groups is set lazily and so retrieving it at this point will cause a traceback because the connection is not yet entered. Also, user doesn't accept anymore groups and properties arguments. diff -r 41ddaf6802f0 -r ca536eec556b cubicweb/pyramid/core.py --- a/cubicweb/pyramid/core.py Mon Jun 06 16:08:03 2016 +0200 +++ b/cubicweb/pyramid/core.py Mon Jun 06 15:37:01 2016 +0200 @@ -348,7 +348,11 @@ log.exception("Failed") raise - return session.user.groups + with session.new_cnx() as cnx: + with cnx.security_enabled(read=False): + return set(group for group, in cnx.execute( + 'Any GN WHERE U in_group G, G name GN, U eid %(userid)s', + {'userid': login})) def includeme(config): diff -r 41ddaf6802f0 -r ca536eec556b cubicweb/pyramid/tools.py --- a/cubicweb/pyramid/tools.py Mon Jun 06 16:08:03 2016 +0200 +++ b/cubicweb/pyramid/tools.py Mon Jun 06 15:37:01 2016 +0200 @@ -27,10 +27,7 @@ None, rset=user.cw_rset.copy(), row=user.cw_row, - col=user.cw_col, - groups=set(user._groups) if hasattr(user, '_groups') else None, - properties=dict(user._properties) - if hasattr(user, '_properties') else None) + col=user.cw_col) clone.cw_attr_cache = dict(user.cw_attr_cache) return clone