本文整理汇总了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)
示例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)
示例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)
示例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)
示例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
}
示例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
}
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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)