当前位置: 首页>>代码示例>>Python>>正文


Python Blog.find_num方法代码示例

本文整理汇总了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)
开发者ID:chris5641,项目名称:simple-blog,代码行数:10,代码来源:handlers.py

示例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
    }
开发者ID:utopiaprince,项目名称:python-blog,代码行数:19,代码来源:handlers.py

示例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
    }
开发者ID:chris5641,项目名称:simple-blog,代码行数:23,代码来源:handlers.py

示例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)
开发者ID:chris5641,项目名称:simple-blog,代码行数:7,代码来源:handlers.py


注:本文中的models.Blog.find_num方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。