本文整理汇总了Python中models.Comment.find_by方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.find_by方法的具体用法?Python Comment.find_by怎么用?Python Comment.find_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.find_by方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_by [as 别名]
def blog(blog_id):
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
blog.html_content = markdown2.markdown(blog.content) # change content to html form
comments = Comment.find_by('where blog_id=? order by created_at desc limit 1000', blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例2: blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_by [as 别名]
def blog(blog_id):
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
#对从数据库中查出的blog内容进行makedown语法格式化
blog.html_content = markdown2.markdown(blog.content)
comments = Comment.find_by('where blog_id=? order by created_at desc limit 100', blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例3: blog
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_by [as 别名]
def blog(blog_id):
import pdb
pdb.set_trace()
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
blog.html_content = markdown2.markdown(blog.content)
comments = Comment.find_by('where blog_id=? order by created_at desc limit 1000',blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例4: api_get_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_by [as 别名]
def api_get_comments():
total = Comment.count_all()
page = Page(total, _get_page_index())
comments = Comment.find_by('order by created_at desc limit ?,?', page.offset, page.limit)
return dict(comments=comments, page=page)