本文整理汇总了Python中data.DataApi.DataApi.addVision方法的典型用法代码示例。如果您正苦于以下问题:Python DataApi.addVision方法的具体用法?Python DataApi.addVision怎么用?Python DataApi.addVision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data.DataApi.DataApi
的用法示例。
在下文中一共展示了DataApi.addVision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addVision
# 需要导入模块: from data.DataApi import DataApi [as 别名]
# 或者: from data.DataApi.DataApi import addVision [as 别名]
def addVision(self, imageUrl, text, isUploaded, isPublic):
'''Creates new vision
TODO: What does isUploaded mean?
Returns (Vision/None, None or error_msg if add vision failed)
'''
#TODO: Save page title and page URL?
if imageUrl == "":
return [None, "No image"]
if len(text.strip()) <= 0:
return [None, "No text"]
pictureId, errorMsg = self._processAndUploadImageUrl(imageUrl, isUploaded)
if pictureId == None:
return [None, "Error saving picture"]
privacy = VisionPrivacy.PUBLIC
if not isPublic:
privacy = VisionPrivacy.PRIVATE
visionId = DataApi.addVision(self.model(), text, pictureId,
0, 0, privacy)
if visionId == DataApi.NO_OBJECT_EXISTS_ID:
return [None, "Error creating vision"]
vision = Vision.getById(visionId, self)
if vision:
return [vision, "Saved Vision!"]
else:
return [None, "Error retrieving vision"]