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


Python Blog.findNumber方法代码示例

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


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

示例1: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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}
开发者ID:naphystart,项目名称:PersonalBlog,代码行数:10,代码来源:handlers.py

示例2: api_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:hellozmz,项目名称:awesome_python3_webapp,代码行数:10,代码来源:handlers.py

示例3: api_index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:naphystart,项目名称:PersonalBlog,代码行数:10,代码来源:handlers.py

示例4: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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}
开发者ID:wp3xpp,项目名称:freemind-python,代码行数:11,代码来源:handlers.py

示例5: get_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:rekonin332,项目名称:p3webapp,代码行数:11,代码来源:handlers.py

示例6: myapi_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:daihaovigg,项目名称:web,代码行数:11,代码来源:handlers.py

示例7: api_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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的中间件处理
开发者ID:Patrickctyyx,项目名称:superawesome-python3-webapp,代码行数:12,代码来源:handlers.py

示例8: api_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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中间件处理
开发者ID:Joe-Blake,项目名称:Blog,代码行数:12,代码来源:handlers.py

示例9: api_private_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:dramenk,项目名称:awesome,代码行数:12,代码来源:handlers.py

示例10: api_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [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)
开发者ID:JasonZhao001,项目名称:awesome-python3-webapp,代码行数:14,代码来源:handlers.py

示例11: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [as 别名]
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)')
    page = Page(num)
    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
    }
开发者ID:windend,项目名称:awesome-python3-webapp,代码行数:15,代码来源:handlers.py

示例12: search_word

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [as 别名]
def search_word(*, type='name', word='1', page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)')
    #select count(id) _num_ from `blogs`    根据id计数,找到blog中所有信息个数
    page = Page(num, page_index)                        #根据页码的信息去找到要传回去的信息个数,起始和终止
    #blogs = yield from Blog.findAll('`name`', like='\'%%C%%\'', orderBy='created_at desc')
    blogs = yield from Blog.findAll('`%s`' % type, like='%s' % word, orderBy='created_at desc', limit=(page.offset, page.limit))
    url = word + '?page='          #值得注意,只需要最后一个变量,多了会出错
    return {
        '__template__': 'search_blogs.html',
        'page': page,
        'blogs': blogs,
        'url': url,
    }
开发者ID:hellozmz,项目名称:awesome_python3_webapp,代码行数:16,代码来源:handlers.py

示例13: user_blogs

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [as 别名]
def user_blogs(id,*, page='1'):
    where_user='user_name='+'\''+id+'\''
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)',where=where_user)
    page = Page(num,page_index=page_index)
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.findAll(where=where_user,orderBy='created_at desc', limit=(page.offset, page.limit))
    return {
        '__template__': 'user_blogs.html',
        'page': page,
        'blogs': blogs,
        'id': id
    }
开发者ID:daihaovigg,项目名称:web,代码行数:17,代码来源:handlers.py

示例14: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [as 别名]
def index(*, page="1"):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber("count(id)")
    page = Page(num)
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.findAll(orderBy="created_at desc", limit=(page.offset, page.limit))
    # 返回一个字典, 其指示了使用何种模板,模板的内容
    # app.py的response_factory将会对handler的返回值进行分类处理
    return{
        "__template__": "blogs.html",
        "page": page,
        "blogs": blogs  # 参数blogs将在jinja2模板中被解析
    }
开发者ID:lovelywxd,项目名称:blogs-web-python,代码行数:17,代码来源:handlers.py

示例15: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import findNumber [as 别名]
def index(*, page='1'):
    #获取页面索引,默认为1;因为首页默认索引页为1,其实这里没用上:
    page_index = get_page_index(page)
    #获取数据库中的文章总数:
    num = yield from Blog.findNumber('count(id)')
    page = Page(num, page_index)
    if num == 0:
        blogs = []
    else:
        #查询数据库中Blog表中对应分页的文章结果;(limit为mysql的分页查询条件)
        blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit))
    return {
        '__template__': 'blogs.html',
        'page': page,
        'blogs': blogs
    }
开发者ID:zhangshengyue,项目名称:text,代码行数:18,代码来源:handlersdetail.py


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