@logged()
    def retrieve_role_and_user_auths(self, username):
        session = self.Session()
        try:
            try:
                user = session.query(model.DbUser).filter_by(login=username).one()
            except NoResultFound:
                raise DbErrors.DbUserNotFoundError("User '%s' not found in database" % username)

            all_user_auths = session.query(model.DbUserAuth).filter_by(user=user).all()
            
            # 
            sorted_user_auths = sorted(all_user_auths, lambda x, y: cmp(x.auth.priority, y.auth.priority))
            if len(sorted_user_auths) > 0:
                return user.login, user.role.name, [ user_auth.to_business() for user_auth in sorted_user_auths ]
            else:
                raise DbErrors.DbNoUserAuthNorPasswordFoundError(
                        "No UserAuth found"
                    )
        finally:
            session.close()
Retrieve the role and user auths for a given username.
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/core/db.py/DatabaseGateway.retrieve_role_and_user_auths