當前位置: 首頁>>代碼示例>>Python>>正文


Python Anno.insert_anno方法代碼示例

本文整理匯總了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)
開發者ID:usersource,項目名稱:anno,代碼行數:30,代碼來源:anno_api.py

示例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()
開發者ID:ignitesol,項目名稱:tasks,代碼行數:13,代碼來源:anno_api.py

示例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()
開發者ID:topcircler,項目名稱:anno,代碼行數:18,代碼來源:anno_api.py


注:本文中的model.anno.Anno.insert_anno方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。