本文整理汇总了Python中data.DataApi.DataApi.getVision方法的典型用法代码示例。如果您正苦于以下问题:Python DataApi.getVision方法的具体用法?Python DataApi.getVision怎么用?Python DataApi.getVision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data.DataApi.DataApi
的用法示例。
在下文中一共展示了DataApi.getVision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getById
# 需要导入模块: from data.DataApi import DataApi [as 别名]
# 或者: from data.DataApi.DataApi import getVision [as 别名]
def getById(visionId, inquiringUser):
'''Get vision by id with privileges of inquiringUser, else None.
If inquiringUser==None, assume public is trying to access this vision.
'''
model = DataApi.getVision(visionId)
if DataApi.NO_OBJECT_EXISTS == model:
return None
vision = Vision(model)
# Ensure that user can access this vision
relationship = Relationship.get(
inquiringUser.id() if inquiringUser else None,
vision.userId())
ok = False
if Relationship.NONE == relationship:
# if no relationship, vision must be public
if VisionPrivacy.PUBLIC == vision.privacy():
ok = True
elif Relationship.SELF == relationship:
# if it is your own vision, you def have access
ok = True
if True == ok:
return vision
else:
return None