495 raise AuthenticationError('user is not in authenticable state') |
495 raise AuthenticationError('user is not in authenticable state') |
496 return cwuser |
496 return cwuser |
497 |
497 |
498 def _build_user(self, session, eid): |
498 def _build_user(self, session, eid): |
499 """return a CWUser entity for user with the given eid""" |
499 """return a CWUser entity for user with the given eid""" |
500 cls = self.vreg['etypes'].etype_class('CWUser') |
500 with session.ensure_cnx_set: |
501 st = cls.fetch_rqlst(session.user, ordermethod=None) |
501 cls = self.vreg['etypes'].etype_class('CWUser') |
502 st.add_eid_restriction(st.get_variable('X'), 'x', 'Substitute') |
502 st = cls.fetch_rqlst(session.user, ordermethod=None) |
503 rset = session.execute(st.as_string(), {'x': eid}) |
503 st.add_eid_restriction(st.get_variable('X'), 'x', 'Substitute') |
504 assert len(rset) == 1, rset |
504 rset = session.execute(st.as_string(), {'x': eid}) |
505 cwuser = rset.get_entity(0, 0) |
505 assert len(rset) == 1, rset |
506 # pylint: disable=W0104 |
506 cwuser = rset.get_entity(0, 0) |
507 # prefetch / cache cwuser's groups and properties. This is especially |
507 # pylint: disable=W0104 |
508 # useful for internal sessions to avoid security insertions |
508 # prefetch / cache cwuser's groups and properties. This is especially |
509 cwuser.groups |
509 # useful for internal sessions to avoid security insertions |
510 cwuser.properties |
510 cwuser.groups |
511 return cwuser |
511 cwuser.properties |
|
512 return cwuser |
512 |
513 |
513 # public (dbapi) interface ################################################ |
514 # public (dbapi) interface ################################################ |
514 |
515 |
515 @deprecated("[4.0] use _cw.call_service('repo_stats'") |
516 @deprecated("[4.0] use _cw.call_service('repo_stats'") |
516 def stats(self): # XXX restrict to managers session? |
517 def stats(self): # XXX restrict to managers session? |