本文整理汇总了Python中models.Comment.findNumber方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.findNumber方法的具体用法?Python Comment.findNumber怎么用?Python Comment.findNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.findNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findNumber [as 别名]
def api_comments(*, page='1'):
page_index = get_page_index(page)
num = yield from Comment.findNumber('count(id)')
p = Page(num, page_index)
if num == 0:
return dict(page=p, comments=())
comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, comments=comments)
示例2: myapi_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findNumber [as 别名]
def myapi_comments(request,*, page='1'):
where_user='to_who='+'\''+request.__user__.name+'\''
page_index = get_page_index(page)
num = yield from Comment.findNumber('count(id)',where=where_user)
p = Page(num, page_index)
if num == 0:
return dict(page=p, comments=())
comments = yield from Comment.findAll(where=where_user,orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, comments=comments)
示例3: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findNumber [as 别名]
def api_comments(*, page="1"):
page_index = get_page_index(page)
num = yield from Comment.findNumber('count(id)') # num为评论总数
p = Page(num, page_index) # 创建page对象, 保存页面信息
if num == 0:
return dict(page=p, comments=()) # 若评论数0,返回字典,将被app.py的response中间件再处理
# 博客总数不为0,则从数据库中抓取博客
# limit强制select语句返回指定的记录数,前一个参数为偏移量,后一个参数为记录的最大数目
comments = yield from Comment.findAll(orderBy="created_at desc", limit=(p.offset, p.limit))
return dict(page=p, comments=comments) # 返回字典,以供response中间件处理
示例4: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findNumber [as 别名]
def api_comments(*, page='1'):
page_index = get_page_index(page)
num = yield from Comment.findNumber('count(id)')
p = Page(num, page_index)
if (num == 0):
return dict(page=p, comments=(), blogs=())
comments = yield from Comment.findAll(orderBy='created_at desc', limit=(
p.offset, p.limit))
blogs = list()
for comment in comments:
comment.blog_name = (yield from Blog.find(comment.blog_id)).name
return dict(page=p, comments=comments, blogs=tuple(blogs))