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


Python Blog.all方法代码示例

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


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

示例1: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def index(request):
    context = base_context()
    rpp = record_per_page()
    cur_page = 1
    try:
        cur_page = int(request.REQUEST["jumpPage"].strip())
    except:
        cur_page = 1

    blogs_count = Blog.all().count()
    max_page = blogs_count / rpp
    temp2 = blogs_count % rpp
    if temp2 != 0:
        max_page = max_page + 1

    if cur_page > max_page or cur_page <= 0:
        cur_page = max_page
        blogs = Blog.all().order("-date").fetch(0)
    else:
        blogs = Blog.all().order("-date").fetch(rpp, rpp * (cur_page - 1))

    context.cur_page = cur_page
    context.max_page = max_page
    context.action_mode = "/"
    context.range1 = range(1, max_page + 1)
    context.up_page = cur_page - 1
    context.down_page = cur_page + 1
    context.blogs = blogs
    template = loader.get_template("blogs/index.html")
    return HttpResponse(template.render(context))
开发者ID:proming,项目名称:myblogongae,代码行数:32,代码来源:views.py

示例2: show_by_archive

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_archive(request, year, month):
    context = base_context()
    rpp = record_per_page()
    cur_page = 1
    try:
        cur_page = int(request.REQUEST["jumpPage"].strip())
    except:
        cur_page = 1

    blogs_count = Blog.all().filter("year", int(year)).filter("month", int(month)).count()
    max_page = blogs_count / rpp
    temp2 = blogs_count % rpp
    if temp2 != 0:
        max_page = max_page + 1

    if cur_page > max_page or cur_page <= 0:
        cur_page = max_page

    if cur_page == 0 or cur_page > max_page:
        cur_page = max_page
        blogs = Blog.all().filter("year", int(year)).filter("month", int(month)).order("-date").fetch(0)
    else:
        blogs = (
            Blog.all()
            .filter("year", int(year))
            .filter("month", int(month))
            .order("-date")
            .fetch(rpp, rpp * (cur_page - 1))
        )

    context.cur_page = cur_page
    context.max_page = max_page
    context.action_mode = "/archive/" + year + "/" + month
    context.range1 = range(1, max_page + 1)
    context.up_page = cur_page - 1
    context.down_page = cur_page + 1
    context.blogs = blogs
    template = loader.get_template("blogs/index.html")
    return HttpResponse(template.render(context))
开发者ID:proming,项目名称:myblogongae,代码行数:41,代码来源:views.py

示例3: base_context

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def base_context():
    context = Context({
        'current_user':current_user(),
        'admin':admin(),
        'login_url':users.create_login_url('/blogs'),
        'logout_url':users.create_logout_url('/blogs'),
        'recent_comments':Comment.all().order('-date').fetch(5),
        'categories':Category.all(),
        'blogs_count':Blog.all().count(),
        'archives':Archive.all().order('-year').order('-month'),
        'friendlyURLs':FriendlyURL.all()
    })
    configuration=Configuration.all().fetch(1)
    if configuration:
        context.configuration=configuration[0]
    return context
开发者ID:qubic,项目名称:myblogongae,代码行数:18,代码来源:views.py

示例4: base_context

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def base_context():
    context = Context(
        {
            "current_user": current_user(),
            "admin": admin(),
            "login_url": users.create_login_url("/blogs"),
            "logout_url": users.create_logout_url("/blogs"),
            "recent_comments": Comment.all().order("-date").fetch(5),
            "categories": Category.all(),
            "blogs_count": Blog.all().count(),
            "archives": Archive.all().order("-year").order("-month"),
            "friendlyURLs": FriendlyURL.all(),
        }
    )
    configuration = Configuration.all().fetch(1)
    if configuration:
        context.configuration = configuration[0]
    else:
        context.configuration = False
    return context
开发者ID:proming,项目名称:myblogongae,代码行数:22,代码来源:views.py

示例5: get

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
 def get(self):
     blogs = Blog.all()
     self.render_template("index.html", {"blogs": blogs})
开发者ID:hackrole,项目名称:GAE_project,代码行数:5,代码来源:blog.py

示例6: show_by_category

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_category(request, key):
    context = base_context()
    blogs = Blog.all().filter('category', Category.get(key)).order('-date')
    context.blogs = blogs
    template = loader.get_template('blogs/index.html')
    return HttpResponse(template.render(context))
开发者ID:qubic,项目名称:myblogongae,代码行数:8,代码来源:views.py

示例7: show_by_archive

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_archive(request, year, month):
    context = base_context()
    blogs = Blog.all().filter('year', int(year)).filter('month', int(month)).order('-date')
    context.blogs = blogs
    template = loader.get_template('blogs/index.html')
    return HttpResponse(template.render(context))
开发者ID:qubic,项目名称:myblogongae,代码行数:8,代码来源:views.py

示例8: index

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def index(request):
    context = base_context()
    blogs = Blog.all().order('-date')
    context.blogs = blogs
    template = loader.get_template('blogs/index.html')
    return HttpResponse(template.render(context))
开发者ID:qubic,项目名称:myblogongae,代码行数:8,代码来源:views.py


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