本文整理汇总了Python中models.Blog.findAll方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.findAll方法的具体用法?Python Blog.findAll怎么用?Python Blog.findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_blogs_in_catgory
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def get_blogs_in_catgory(*, page='1', id):
page_index = get_page_index(page)
try:
num = (yield from calcu_relation_num(int(id), hide_ignore = True))
except ValueError as e:
logging.info('ValueError:', e)
return 'redirect:/'
finally:
pass
page = Page(num, page_index)
blogs_in_catgory = []
if num == 0:
blogs = []
else:
blogs = yield from Blog.findAll('hide=?', [False], orderBy='created_at desc')
for blog in blogs:
if ((blog.categorys_bit >> (int)(id)) & 1) == 1:
blog.categorys_tag = yield from categorys_bit2tag(blog.categorys_bit)
blogs_in_catgory.append(blog)
categorys = yield from Category.findAll(orderBy='weight desc')
for category in categorys:
category.relationNum = (yield from calcu_relation_num(category.id, hide_ignore = True))
return {
'__template__': 'blogs.html',
'page': page,
'blogs': blogs_in_catgory[page.offset : (page.offset + page.limit - 1)],
'categorys': categorys
}
示例2: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def index(*, page="1"):
page_index = get_page_index(page)
num = yield from Blog.findNumber("count(id)")
p = Page(num, page_index, page_size=5)
blogs = yield from Blog.findAll(orderBy="created_at desc", limit=(p.offset, p.limit))
for blog in blogs:
blog.html_summary = markdown2.markdown(blog.summary)
return {"__template__": "blogs.html", "page_index": get_page_index(page), "blogs": blogs}
示例3: api_index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_index(*, page="1"):
page_index = get_page_index(page)
num = yield from Blog.findNumber("count(id)")
p = Page(num, page_index, page_size=5)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.findAll(orderBy="created_at desc", limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs)
示例4: api_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_blogs(*, page='1'):
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)')
p = Page(num, page_index)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs)
示例5: get_user
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def get_user(id):
user = yield from User.find(id)
blogs = yield from Blog.findAll('user_id=?', [id], orderBy='created_at desc')
return {
'__template__': 'user.html',
'user': user,
'blogs': blogs
}
示例6: get_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def get_blogs(*, p_index=1):
int_index = get_page_index(p_index)
num = yield from Blog.findNumber('count(id)')
p = Page(num, int_index, page_size=5)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs)
示例7: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def index(*, request, page='1'):
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)')
#page = Page(num)
page = Page(num, page_index)
if num == 0:
blogs = []
else:
admin=is_admin(request)
if admin:
blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit))
else:
blogs = yield from Blog.findAll('private_blogs=?', [0], orderBy='created_at desc', limit=(page.offset, page.limit))
return {
'__template__': 'blogs.html',
'page': page,
'blogs': blogs
}
示例8: myapi_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def myapi_blogs(request,*, page='1'):
where_user='user_name='+'\''+request.__user__.name+'\''
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)',where=where_user)
p = Page(num, page_index)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.findAll(where=where_user,orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs)
示例9: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def index(*, page="1"):
page_index = get_page_index(page)
num = yield from Blog.findNumber("count(id)")
page = Page(num, page_index)
if num == 0:
blogs = []
else:
blogs = yield from Blog.findAll(orderBy="created_at desc", limit=(page.offset, page.limit))
return {"__template__": "blogs.html", "page": page, "blogs": blogs}
示例10: api_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_blogs(*, page='1'):
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)') # num为博客总数
p =Page(num, page_index) # 创建page对象
if num ==0:
return dict(page=p, blogs=())
# 博客书不为0就从数据库中抓取博客
# limit强制select返回指定的记录数
blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs) # 返回dict,以供response的中间件处理
示例11: api_private_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_private_blogs(*, page='1'):
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)')
p = Page(num, page_index, page_size=20)
if num == 0:
return dict(page=p, blogs=())
blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
for blog in blogs:
blog.content = ''
return dict(page=p, blogs=blogs)
示例12: api_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_blogs(*, page='1'):
page_index = get_page_index(page)
num = yield from Blog.findNumber('count(id)') # num为博客总数
p = Page(num, page_index) # 创建page对象
if num == 0:
return dict(page=p, blogs=()) # 若博客数为0,返回字典,将被app.py的response中间件再处理
# 博客总数不为0,则从数据库中抓取博客
# limit强制select语句返回指定的记录数,前一个参数为偏移量,后一个参数为记录的最大数目
blogs = yield from Blog.findAll(orderBy="created_at desc", limit=(p.offset, p.limit))
return dict(page=p, blogs=blogs) # 返回字典,以供response中间件处理
示例13: get_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def get_blog(blog_id):
blog = yield from Blog.find(blog_id)
comments = yield from Blog.findAll('blog_id = ?', [blog_id], orderBy = 'created_at desc')
for c in comments:
c.html_content = text2html(c.content)
blog.html_content = markdown2.markdown(blog.content)
return {
'__template__': 'blogs.html',
'blog': blog,
'comments': comments
}
示例14: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def index(request):
blogs = yield from Blog.findAll(orderBy='created_at desc')
for blog in blogs:
blog.html_content = markdown2.markdown(blog.content)
return {
'__template__': 'blogs.html',
'blogs': blogs
}
示例15: api_blogs
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findAll [as 别名]
def api_blogs(*, page = '1'):
# 获取博客信息,调用位置:manage_blogs.html 40行
'''
请参考29行的api_get_users函数的注释
'''
page_index = get_page_index(page)
blog_count = yield from Blog.findNumber('count(id)')
p = Page(blog_count, page_index)
if blog_count == 0:
return dict(page = p, blogs = [])
blogs = yield from Blog.findAll(orderBy = 'created_at desc', limit = (p.offset, p.limit))
return dict(page = p, blogs = blogs)