当前位置: 首页>>代码示例>>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;未经允许,请勿转载。