本文整理汇总了Python中models.Blog.find_num方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.find_num方法的具体用法?Python Blog.find_num怎么用?Python Blog.find_num使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.find_num方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_num [as 别名]
def api_blogs(*, page='1'):
page_index = get_page_index(page)
num = yield from Blog.find_num('count(id)')
p = Page(num, page_index)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.find_all(orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs)
示例2: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_num [as 别名]
def index(*, page='1'):
page_index = Page.get_index(page)
num = yield from Blog.find_num('count(id)')
page = Page(num, page_index)
if num == 0:
blogs = []
else:
blogs = yield from Blog.find_all(orderBy='created_at desc',
limit=(page.offset, page.limit))
for blog in blogs:
# blog.summary = markdown_highlight(blog.summary)
blog.html_content = markdown_highlight(blog.content)
return {
'__template__': 'bootstrap-blogs.html',
'page': page,
'blogs': blogs
}
示例3: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_num [as 别名]
def index(*, page='1'):
# summary = 'it is a test!\n这里可以添加文字'
# blogs = [
# Blog(id='1', name='test blog', summary=summary, created_at=time.time()-120),
# Blog(id='2', name='测试标题!!', summary=summary, created_at=time.time()-120),
# Blog(id='3', name='nice', summary=summary, created_at=time.time()-120),
# Blog(id='4', name='哈哈哈哈哈哈哈', summary=summary, created_at=time.time()-120),
# ]
# users = yield from User.find_all()
page_index = get_page_index(page)
num = yield from Blog.find_num('count(id)')
page = Page(num, page_index)
if num == 0:
blogs = []
else:
blogs = yield from Blog.find_all(orderBy='created_at desc', limit=(page.offset, page.limit))
return {
'__template__': 'blogs.html',
'page': page,
'blogs': blogs
}
示例4: api_delete_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_num [as 别名]
def api_delete_blog(request, *, id):
check_admin(request)
blog = yield from Blog.find_num(id)
yield from blog.remove()
return dict(id=id)