本文整理汇总了Python中model.anno.Anno.query_by_country方法的典型用法代码示例。如果您正苦于以下问题:Python Anno.query_by_country方法的具体用法?Python Anno.query_by_country怎么用?Python Anno.query_by_country使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.anno.Anno
的用法示例。
在下文中一共展示了Anno.query_by_country方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: anno_list
# 需要导入模块: from model.anno import Anno [as 别名]
# 或者: from model.anno.Anno import query_by_country [as 别名]
def anno_list(self, request):
"""
Exposes an API endpoint to retrieve a list of anno.
"""
user = auth_user(self.request_state.headers)
limit = 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
if request.select is not None:
select_projection = request.select.split(',')
if request.query_type == 'by_created':
return Anno.query_by_app_by_created(request.app, limit, select_projection, curs)
elif request.query_type == 'by_vote_count':
return Anno.query_by_vote_count(request.app)
elif request.query_type == 'by_flag_count':
return Anno.query_by_flag_count(request.app)
elif request.query_type == 'by_activity_count':
return Anno.query_by_activity_count(request.app)
elif request.query_type == 'by_last_activity':
return Anno.query_by_last_activity(request.app)
elif request.query_type == 'by_country':
return Anno.query_by_country(request.app)
else:
return Anno.query_by_page(limit, select_projection, curs)
示例2: anno_list
# 需要导入模块: from model.anno import Anno [as 别名]
# 或者: from model.anno.Anno import query_by_country [as 别名]
def anno_list(self, request):
"""
Exposes an API endpoint to retrieve a list of anno.
"""
user = auth_user(self.request_state.headers)
limit = 10
if request.limit is not None:
limit = request.limit
is_plugin = request.is_plugin or False
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
if request.select is not None:
select_projection = request.select.split(',')
if request.query_type == AnnoQueryType.CREATED:
return Anno.query_by_app_by_created(request.app, limit, select_projection, curs, user)
elif request.query_type == AnnoQueryType.VOTE_COUNT:
return Anno.query_by_vote_count(request.app, user)
elif request.query_type == AnnoQueryType.FLAG_COUNT:
return Anno.query_by_flag_count(request.app, user)
elif request.query_type == AnnoQueryType.ACTIVITY_COUNT:
return Anno.query_by_activity_count(request.app, user)
elif request.query_type == AnnoQueryType.LAST_ACTIVITY:
return Anno.query_by_last_activity(request.app, user)
elif request.query_type == AnnoQueryType.COUNTRY:
return Anno.query_by_country(request.app, user)
elif request.query_type == AnnoQueryType.COMMUNITY:
community = Community.get_by_id(request.community)
return Anno.query_by_community(community, limit, select_projection, curs, user)
elif request.query_type == AnnoQueryType.APP:
app = AppInfo.get(request.app)
return Anno.query_by_app(app, limit, select_projection, curs, user)
else:
return Anno.query_by_page(limit, select_projection, curs, user, is_plugin)