本文整理汇总了Python中rogerthat.models.UserProfile.list_by_service_role_email方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.list_by_service_role_email方法的具体用法?Python UserProfile.list_by_service_role_email怎么用?Python UserProfile.list_by_service_role_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rogerthat.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.list_by_service_role_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_service_grants
# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import list_by_service_role_email [as 别名]
def get_service_grants(service_user, filtered_service_identity=ServiceIdentity.DEFAULT, filtered_role_id=None,
filtered_role_type=None):
from rogerthat.bizz.roles import ROLE_TYPE_ADMIN, ROLE_TYPE_SERVICE
service_user_email = service_user.email()
if not isinstance(service_user_email, unicode):
service_user_email = service_user_email.decode('utf-8')
profiles = UserProfile.list_by_service_role_email(service_user_email)
for p in profiles:
for si, roles in p.grants.iteritems():
if si.startswith(service_user_email + '/'):
_, identity = get_service_identity_tuple(users.User(si))
if filtered_service_identity != ServiceIdentity.DEFAULT and identity != filtered_service_identity:
continue
for role in roles:
gto = GrantTO()
try:
role_id = int(role)
role_type = ROLE_TYPE_SERVICE
role = None
except ValueError: # build-int role (see ROLES constant)
role_id = -1
role_type = ROLE_TYPE_ADMIN
gto.role_type = role_type
gto.role_id = role_id
gto.role = role
if filtered_role_id is not None and filtered_role_id != gto.role_id:
continue
if filtered_role_type is not None and filtered_role_type != gto.role_type:
continue
gto.identity = identity
gto.service_email = service_user_email
gto.user_email = get_human_user_from_app_user(p.user).email()
gto.user_name = p.name
gto.user_avatar_id = p.avatarId
gto.app_id = p.app_id
yield gto