本文整理汇总了Python中model.anno.Anno.insert_anno方法的典型用法代码示例。如果您正苦于以下问题:Python Anno.insert_anno方法的具体用法?Python Anno.insert_anno怎么用?Python Anno.insert_anno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.anno.Anno
的用法示例。
在下文中一共展示了Anno.insert_anno方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: anno_insert
# 需要导入模块: from model.anno import Anno [as 别名]
# 或者: from model.anno.Anno import insert_anno [as 别名]
def anno_insert(self, request):
"""
Exposes an API endpoint to insert an anno for the current user.
if current user doesn't exist, the user will be created first.
"""
user = auth_user(self.request_state.headers)
# checking if same anno exists
exist_anno = Anno.is_anno_exists(user, request)
if exist_anno is not None:
raise endpoints.BadRequestException("Duplicate anno(%s) already exists." % exist_anno.key.id())
entity = Anno.insert_anno(request, user)
# find all hashtags
tags = extract_tags_from_text(entity.anno_text.lower())
for tag, count in tags.iteritems():
# Write the cumulative amount per tag
Tag.add_tag_total(tag, total=count)
# index this document. strange exception here.
put_search_document(entity.generate_search_document(), SearchIndexName.ANNO)
# send push notifications
ActivityPushNotifications.send_push_notification(first_user=user, anno=entity, action_type=AnnoActionType.CREATED)
return entity.to_response_message(user)
示例2: anno_insert
# 需要导入模块: from model.anno import Anno [as 别名]
# 或者: from model.anno.Anno import insert_anno [as 别名]
def anno_insert(self, request):
"""
Exposes an API endpoint to insert an anno for the current user.
if current user doesn't exist, the user will be created first.
"""
user = auth_user(self.request_state.headers)
if Anno.is_anno_exists(user, request):
raise endpoints.BadRequestException("Duplicate anno already exists.")
entity = Anno.insert_anno(request, user)
return entity.to_response_message()
示例3: anno_insert
# 需要导入模块: from model.anno import Anno [as 别名]
# 或者: from model.anno.Anno import insert_anno [as 别名]
def anno_insert(self, request):
"""
Exposes an API endpoint to insert an anno for the current user.
if current user doesn't exist, the user will be created first.
"""
user = auth_user(self.request_state.headers)
exist_anno = Anno.is_anno_exists(user, request)
if exist_anno is not None:
raise endpoints.BadRequestException("Duplicate anno(%s) already exists." % exist_anno.key.id())
entity = Anno.insert_anno(request, user)
# index this document. strange exception here.
put_search_document(entity.generate_search_document())
return entity.to_response_message()