本文整理匯總了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()