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


Python Blog.find_all方法代码示例

本文整理汇总了Python中models.Blog.find_all方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.find_all方法的具体用法?Python Blog.find_all怎么用?Python Blog.find_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Blog的用法示例。


在下文中一共展示了Blog.find_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: archive

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def archive():
    # 获取年
    years = Blog.find_all(groupby='year')
    # 根据‘year’获取不同年的blog数据
    blogs = []
    for year_blog in years:
        year = year_blog.year
        # 根据year获取该年的blogs
        blogs_year = Blog.find_all('year= ?', [year], orderBy='created_at desc')
        mylog.info(blogs_year)
        blogs.append(blogs_year)
    return render_template('archive.html', blogs=blogs)
开发者ID:fantianwen,项目名称:web_blog,代码行数:14,代码来源:app.py

示例2: welcome

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def welcome():
    session['page_number'] = 1
    blogs = Blog.find_all(orderBy='created_at desc', limit=(0, 8))
    for blog in blogs:
        md = highlight.parse2markdown(blog.summary)
        blog.md_summary = md

    # 侧边栏的分类
    blog_categories = Blog.find_all(groupby='category')
    blogs_categories = []
    for category in blog_categories:
        blog_catrgory = Blog.find_all('category=?', [category.category])
        blogs_categories.append(blog_catrgory)
    return render_template('welcome.html', blogs=blogs, blogs_categories=blogs_categories)
开发者ID:fantianwen,项目名称:web_blog,代码行数:16,代码来源:app.py

示例3: show_page

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def show_page(page_number):
    int_page_number = int(page_number)
    session['page_number'] = int_page_number
    if page_number == 1:
        return redirect('/')
    blogs = Blog.find_all(orderBy='created_at desc', limit=((int_page_number - 1) * 8, 8))

    blog_categories = Blog.find_all(groupby='category')
    blogs_categories = []
    for category in blog_categories:
        blog_catrgory = Blog.find_all('category=?', [category.category])
        blogs_categories.append(blog_catrgory)

    return render_template('welcome.html', blogs=blogs, blogs_categories=blogs_categories)
开发者ID:fantianwen,项目名称:web_blog,代码行数:16,代码来源:app.py

示例4: api_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [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

示例5: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [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

示例6: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [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

示例7: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
    blogs, page = _get_blogs_by_page()
    blogs = Blog.find_all()
    summary = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
    fakeblogs =[Blog(id='2', name='Test Blog', summary=summary, created_at=time.time()-120),
        Blog(id='3', name='Something New', summary=summary, created_at=time.time()-3600),
        Blog(id='4', name='Learn Swift', summary=summary, created_at=time.time()-7200),
        Blog(id='5', name='Test Blog2', summary=summary, created_at=time.time()-120),
        Blog(id='6', name='Something New2', summary=summary, created_at=time.time()-3600),
        Blog(id='7', name='Learn Swift2', summary=summary, created_at=time.time()-7200),
        Blog(id='8', name='Test Blog3', summary=summary, created_at=time.time()-120),
        Blog(id='9', name='Something New3', summary=summary, created_at=time.time()-3600),
        Blog(id='10', name='Learn Swift3', summary=summary, created_at=time.time()-7200),
        Blog(id='11', name='Test Blog4', summary=summary, created_at=time.time()-120),
        Blog(id='12', name='Something New4', summary=summary, created_at=time.time()-3600),
        Blog(id='13', name='Learn Swift4', summary=summary, created_at=time.time()-7200)]
    for i in fakeblogs:
        blogs.append(i)

    #查找登陆用户:
    #user = User.find_first("where email=?", "[email protected]")

    return dict(page=page, blogs=blogs, user=ctx.request.user)
开发者ID:danolphoenix,项目名称:awesome-python-webapp,代码行数:25,代码来源:urls.py

示例8: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
    blogs = Blog.find_all()
    for p in blogs:
        p.summary = markdown(p.summary)
    return dict(blogs=blogs,user=ctx.request.user)
开发者ID:wenhuwang,项目名称:awesome-webapp,代码行数:7,代码来源:urls.py

示例9: all_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def all_blogs():
    blogs = Blog.find_all()
    blogs = sorted(blogs,key=lambda blog:blog.created_at,reverse=True)
    blogs = render_blogs(blogs)
    user = ctx.request.user
    return dict(blogs=blogs,user=user)
开发者ID:lixiangbest,项目名称:jblog,代码行数:8,代码来源:urls.py

示例10: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
    blogs = Blog.find_all()
    user = ctx.request.user
    return dict(blogs=blogs, user=user)
开发者ID:SharpZKing,项目名称:awesome-python-webapp,代码行数:6,代码来源:urls.py

示例11: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
	blogs = Blog.find_all()
	# user = User.find_first("where email = ?", "[email protected]")
	return dict(blogs = blogs)
开发者ID:lgknight,项目名称:awesome-python-webapp,代码行数:6,代码来源:urls.py

示例12: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
    blogs = Blog.find_all()
    user = User.find_first('where email=?', '[email protected]')
    return dict(blogs=blogs, user=user)
开发者ID:booxiong,项目名称:awesome-python-webapp,代码行数:6,代码来源:urls.py

示例13: _get_blogs_by_page

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def _get_blogs_by_page():
    total = Blog.count_all()
    page = Page(total, _get_page_index)
    blogs = Blog.find_all('order by created_at desc limit ?,?', page.offset, page.limit)
    return blogs, page
开发者ID:qxsound,项目名称:blog-python-webapp,代码行数:7,代码来源:urls.py

示例14: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def index():
    blogs = Blog.find_all()
    # 查找登录用户:
    # user = User.find_first('where email=?', '[email protected]')
    return dict(blogs=blogs, user=ctx.request.user)
开发者ID:ljlok,项目名称:awesome-py-webapp,代码行数:7,代码来源:urls.py

示例15: get_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find_all [as 别名]
def get_blogs(page_number):
    int_page_number = int(page_number)
    blogs = Blog.find_all(orderBy='created_at desc', limit=((int_page_number - 1) * 8, 8))
    return jsonify(blogs=blogs)
开发者ID:fantianwen,项目名称:web_blog,代码行数:6,代码来源:app.py


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