def user_roles_by_tenant(self, user_id, tenant_id, session=None): if not session: session = get_session() result = session.query(models.UserRoleAssociation).\ filter_by(user_id=user_id, tenant_id=tenant_id).\ options(joinedload('roles')) return result
def user_roles_by_tenant(self, user_id, tenant_id, session=None): if not session: session = get_session() if hasattr(api.USER, 'uid_to_id'): user_id = api.USER.uid_to_id(user_id) if hasattr(api.TENANT, 'uid_to_id'): tenant_id = api.TENANT.uid_to_id(tenant_id) results = session.query(models.UserRoleAssociation).\ filter_by(user_id=user_id, tenant_id=tenant_id).\ options(joinedload('roles')) for result in results: if hasattr(api.USER, 'id_to_uid'): result.user_id = api.USER.id_to_uid(result.user_id) if hasattr(api.TENANT, 'id_to_uid'): result.tenant_id = api.TENANT.id_to_uid(result.tenant_id) return results