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


Python BlogPost.all方法代码示例

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


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

示例1: generate_resource

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
    def generate_resource(cls, post, resource, pagenum=1, start_ts=None):
        from blog.models import BlogPost
        q = BlogPost.all().order('-published')
        q.filter('published <', start_ts or datetime.datetime.max)
        cls._filter_query(resource, q)

        posts = q.fetch(config.posts_per_page + 1)
        more_posts = len(posts) > config.posts_per_page

        path_args = {
            'resource': resource,
        }
        path_args['pagenum'] = pagenum - 1
        prev_page = cls.path % path_args
        path_args['pagenum'] = pagenum + 1
        next_page = cls.path % path_args
        template_vals = {
            'posts': posts[:config.posts_per_page],
            'prev_page': prev_page if pagenum > 1 else None,
            'next_page': next_page if more_posts else None,
            'config': config,
        }
        template_name = "blog/themes/%s/listing.html" % config.theme
        rendered = utils.render_template(template_name, template_vals)
        
        path_args['pagenum'] = pagenum
        StaticContent.set(cls.path % path_args, rendered, config.html_mime_type)

        if pagenum == 1:
            StaticContent.set(cls.first_page_path % path_args, rendered, config.html_mime_type)
        if more_posts:
            deferred.defer(cls.generate_resource, None, resource, pagenum + 1,
                           posts[-2].published)
开发者ID:calvinchengx,项目名称:O-Kay-Blog-wih-Kay-0.10.0,代码行数:35,代码来源:generators.py

示例2: index

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
def index(request):
    """Displays the index page."""
    # Fetch all of the BlogPosts
    posts = BlogPost.all().order('-date')

    # Setup the data to pass on to the template
    template_values = {
        'posts': posts,
    }

    # Load and render the template
    return shortcuts.render_to_response('index.html', template_values)
开发者ID:kenglishhi,项目名称:gae-django-sandbox,代码行数:14,代码来源:views.py

示例3: view

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
def view(request, post_uri):
    # Find the requested post
    post = BlogPost.all().filter('uri = ', post_uri).fetch(1)

    # Make sure the requested post exists
    if post == None or len(post) == 0:
        return http.HttpResponseNotFound('No post exists with that uri (%r)' % post_uri)

    # Get the requested post data
    post = post[0]

    # Load and display the view template
    return shortcuts.render_to_response('view.html', {'post': post})
开发者ID:vLj2,项目名称:appengine_django_blog,代码行数:15,代码来源:views.py

示例4: regenerate

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
def regenerate(batch_size=50, seen=None, start_ts=None):
    """Regenerate all static content"""
    if not seen:
        seen = set()
    q = BlogPost.all().order('-published')
    q.filter('published <', start_ts or datetime.datetime.max)
    posts = q.fetch(batch_size)
    for post in posts:
        for generator_class, deps in post.get_deps(True):
            for dep in deps:
                if (generator_class.__name__, dep) not in seen:
                    logging.warn((generator_class.__name__, dep))
                    seen.add((generator_class.__name__, dep))
                    deferred.defer(generator_class.generate_resource, None, dep)
    if len(posts) == batch_size:
        deferred.defer(regenerate, batch_size, seen, posts[-1].published)
开发者ID:calvinchengx,项目名称:O-Kay-Blog-wih-Kay-0.10.0,代码行数:18,代码来源:post_deploy.py

示例5: index

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
def index(request, start=0, count=10):
    offset = start
    more_posts = False 
    posts = BlogPost.all().order('-published').fetch(count+1, offset)
    if len(posts) > count:
        posts = posts[0:count]
        more_posts = True
    template_vals = {
            'offset': offset,
            'count': count,
            'last_post': offset + len(posts) - 1,
            'prev_offset': max(0, offset - count),
            'next_offset': offset + count,
            'posts': posts,
            'more_posts': more_posts,
            'config': config,
            'menu_view': True,
            }
    return render_to_response("blog/admin/index.html", template_vals)
开发者ID:calvinchengx,项目名称:O-Kay-Blog-wih-Kay-0.10.0,代码行数:21,代码来源:admin.py

示例6: get_context_data

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import all [as 别名]
 def get_context_data(self, **kwargs):
     context = super(BlogIndex, self).get_context_data(**kwargs)
     # Latest 10 posts.
     context['posts'] = BlogPost.all().order('-date').fetch(10)
     return context
开发者ID:bensums,项目名称:blog-exercise,代码行数:7,代码来源:views.py


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