本文整理汇总了Python中models.Comment.findAll方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.findAll方法的具体用法?Python Comment.findAll怎么用?Python Comment.findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
blog = yield from Blog.find(id)
comments = yield from Comment.findAll("blog_id=?", [id], orderBy="created_at desc")
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content).replace("\n", "</br>")
return {"__template__": "blog.html", "blog": blog, "comments": comments}
示例2: api_delete_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_delete_blog(id, request):
check_admin(request)
blog = yield from Blog.find(id)
comments = yield from Comment.findAll(where="blog_id='%s'" % id)
yield from blog.remove()
for comment in comments:
yield from comment.remove()
return dict(id=id)
示例3: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [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)
示例4: myapi_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [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)
示例5: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
# 通过id在数据库Blog表中查询对应内容:
blog = yield from Blog.find(id)
# 通过id在数据库Comment表中查询对应内容:
comments = yield from Comment.findAll("blog_id=?", [id], orderBy="created_at desc")
for c in comments:
# 将content值从text格式转换成html格式:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content)
return {"__template__": "blog.html", "blog": blog, "comments": comments}
示例6: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [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中间件处理
示例7: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
blog = yield from Blog.find(id)
comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content)
return {
'__template__': 'blog.html',
'blog': blog,
'comments': comments
}
示例8: api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [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))
示例9: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
blog = yield from Blog.find(id) # 通过id从数据库拉取博客信息
# 从数据库拉取指定blog的所有评论,按时间顺序降序排序
comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
# 将每条评论都转化成html格式
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content) # blog是markdown格式,转化成html
return {
# 返回的参数将在jinja2模板中被解析
'__template__': 'blog.html',
'blog': blog,
'comments': comments
}
示例10: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
blog = yield from Blog.find(id) # 通过id从数据库拉取博客信息
# 从数据库拉取指定blog的全部评论,按时间降序排序,即最新的排在最前
comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
# 将每条评论都转化为html格式(根据text2html代码可知,实际为html的<p>)
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content) # blog是markdown格式,将其转换为html格式
return {
# 返回的参数将在jinja2模板中被解析
"__template__": "blog.html",
"blog": blog,
"comments": comments
}
示例11: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
# 根据博客id查询该博客信息
blog = yield from Blog.find(id)
# 根据博客id查询该条博客的评论
comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
# markdown2是个扩展模块,这里把博客正文和评论套入到markdonw2中
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content)
# 返回页面
# /api/blogs/{{ blog.id }}/comments
return {'__template__': 'blog.html',
'blog': blog,
'comments': comments}
示例12: get_interface
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_interface(id):
#根据APIid查询该API信息
interface = yield from Interface.find(id)
#根据APIid查询该API评论
comments = yield from Comment.findAll('interface_id=?', [id], orderBy='created_at desc')
#markdown2是个扩展模块,把API正文和评论套入markdown2中
for c in comments:
c.html_content = text2html(c.content)
interface.html_content = markdown2.markdown(interface.content)
#返回页面
return {
'__template__': 'interface.html',
'interface': interface,
'comments': comments
}
示例13: get_blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(*, request, id):
blog = yield from Blog.find(id)
if blog.hide == True:
if request.__user__ is None or not request.__user__.admin:
return 'redirect:/'
comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content)
blog.categorys_tag = (yield from categorys_bit2tag(blog.categorys_bit))
return {
'__template__': 'blog.html',
'blog': blog,
'comments': comments
}
示例14: get_api_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_api_comments(*,page=1):
comments= yield from Comment.findAll( orderBy='created_at')
print('###################################################')
print(comments)
print('###################################################')
return dict(comments=comments)
示例15: get_api_comments_by_blog_id
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_api_comments_by_blog_id(blog_id):
comments=yield from Comment.findAll('`blog_id` = ?', [blog_id], orderBy='created_at')
return comments