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


Python Anno.query方法代碼示例

本文整理匯總了Python中model.anno.Anno.query方法的典型用法代碼示例。如果您正苦於以下問題:Python Anno.query方法的具體用法?Python Anno.query怎麽用?Python Anno.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在model.anno.Anno的用法示例。


在下文中一共展示了Anno.query方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list_favorite_apps

# 需要導入模塊: from model.anno import Anno [as 別名]
# 或者: from model.anno.Anno import query [as 別名]
    def list_favorite_apps(cls, user_key):
        # We are using "query" on key for getting anno data instead of "get" or "get_multi"
        # Getting anno using "query" is more memory efficient than using "get" or "get_multi",
        # we don't know why.
        # Getting anno using "query" also create index for this.

        from model.userannostate import UserAnnoState
        from model.anno import Anno

        userannostate_list = UserAnnoState.list_by_user(user_key, 50)
        anno_key_list = [ userannostate.anno for userannostate in userannostate_list if userannostate.anno is not None ]

        if len(anno_key_list):
            anno_list = Anno.query(ndb.AND(Anno.key.IN(anno_key_list),
                                           Anno.app != None)
                                   )\
                            .fetch(projection=[Anno.app])
            app_key_list = [ anno.app for anno in anno_list ]
            app_key_list = sorted(app_key_list, key=app_key_list.count, reverse=True)
            unique_app_key_list = []
            [ unique_app_key_list.append(app_key) for app_key in app_key_list if app_key not in unique_app_key_list ]
            app_list = ndb.get_multi(unique_app_key_list)
        else:
            app_list = []

        favorite_apps_list = []
        for app in app_list:
            if app:
                app_message = UserFavoriteApp(name=app.name, icon_url=(app.icon_url or ""), version=(app.version or ""))
                favorite_apps_list.append(app_message)

        return favorite_apps_list
開發者ID:usersource,項目名稱:anno,代碼行數:34,代碼來源:user.py

示例2: init_index_document

# 需要導入模塊: from model.anno import Anno [as 別名]
# 或者: from model.anno.Anno import query [as 別名]
 def init_index_document(self, request):
     """
     Exposes an API endpoint to insert search document for legacy documents.
     """
     for anno in Anno.query():
         logging.info("generating search document for anno(%s)." % anno.key.id())
         put_search_document(anno.generate_search_document(), SearchIndexName.ANNO)
     return message_types.VoidMessage()
開發者ID:usersource,項目名稱:anno,代碼行數:10,代碼來源:util_api.py

示例3: migrate_photo_time_annos

# 需要導入模塊: from model.anno import Anno [as 別名]
# 或者: from model.anno.Anno import query [as 別名]
def migrate_photo_time_annos(cursor=None):
    team_key = 'us.orbe.Reko-Album'
    phototime_app = AppInfo.query().filter(AppInfo.lc_name == 'phototime').get()
    phototime_community = Community.getCommunityFromTeamKey(team_key=team_key)
    anno_list = Anno.query().filter(Anno.app == phototime_app.key).fetch()

    for anno in anno_list:
        anno.community = phototime_community.key
        user_email = anno.creator.get().user_email
        anno.creator = User.find_user_by_email(email=user_email, team_key=team_key).key
        anno.put()
開發者ID:usersource,項目名稱:anno,代碼行數:13,代碼來源:update_schema_handler.py

示例4: anno_list

# 需要導入模塊: from model.anno import Anno [as 別名]
# 或者: from model.anno.Anno import query [as 別名]
    def anno_list(self, request):
        """
        Exposes an API endpoint to retrieve a list of anno.
        """
        limit = 10  # default limit is 10.
        if request.limit is not None:
            limit = request.limit

        curs = None
        if request.cursor is not None:
            try:
                curs = Cursor(urlsafe=request.cursor)
            except BadValueError:
                raise endpoints.BadRequestException('Invalid cursor %s.' % request.cursor)

        select_projection = None
        # todo: add projection validation, may need metadata.
        if request.select is not None:
            select_projection = request.select.split(',')

        if (curs is not None) and (select_projection is not None):
            annos, next_curs, more = Anno.query().fetch_page(limit, start_cursor=curs, projection=select_projection)
        elif (curs is not None) and (select_projection is None):
            annos, next_curs, more = Anno.query().fetch_page(limit, start_cursor=curs)
        elif (curs is None) and (select_projection is not None):
            annos, next_curs, more = Anno.query().fetch_page(limit, projection=select_projection)
        else:
            annos, next_curs, more = Anno.query().fetch_page(limit)

        if select_projection is not None:
            items = [entity.to_response_message_by_projection(select_projection) for entity in annos]
        else:
            items = [entity.to_response_message() for entity in annos]

        if more:
            return AnnoListMessage(anno_list=items, cursor=next_curs.urlsafe(), has_more=more)
        else:
            return AnnoListMessage(anno_list=items, has_more=more)
開發者ID:ignitesol,項目名稱:tasks,代碼行數:40,代碼來源:anno_api.py

示例5: update_anno_schema

# 需要導入模塊: from model.anno import Anno [as 別名]
# 或者: from model.anno.Anno import query [as 別名]
def update_anno_schema(cursor=None):
    anno_list, cursor, more = Anno.query().fetch_page(BATCH_SIZE, start_cursor=cursor)

    anno_update_list = []
    for anno in anno_list:
        # updating anno schema for plugin
        if not anno.archived:
            anno.archived = False
            anno_update_list.append(anno)

        # updating app for anno schema
#         if not anno.app:
#             appinfo = AppInfo.get(name=anno.app_name)
#
#             if appinfo is None:
#                 appInfoMessage = AppInfoMessage(name=anno.app_name, version=anno.app_version)
#                 appinfo = AppInfo.insert(appInfoMessage)
#
#             anno.app = appinfo.key
#             anno_update_list.append(anno)

        # updating anno schema for community
#         if not anno.community:
#             anno.community = None
#             anno_update_list.append(anno)

        # updating anno schema for anno_id
#         if not anno.anno_id:
#             anno.anno_id = anno.key.id()
#             anno_update_list.append(anno)

        # updating userannostate from anno
#         update_userannostate_schema_from_anno(anno)

        # updating anno index
#         regenerate_index(anno, SearchIndexName.ANNO)

        # extract tag
#         create_tags(anno.anno_text)

    if len(anno_update_list):
        ndb.put_multi(anno_update_list)

    if more:
        update_anno_schema(cursor=cursor)
開發者ID:usersource,項目名稱:anno,代碼行數:47,代碼來源:update_schema_handler.py


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