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


Python Post.get_post_page_count方法代码示例

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


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

示例1: test_new_non_published_post_does_not_purge_page_count_cache

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_post_page_count [as 别名]
    def test_new_non_published_post_does_not_purge_page_count_cache(self):
        self._create_test_posts()

        Post.get_post_page_count()

        self.assertIsNotNone(memcache.get(Post._page_count_memcached_key))

        Post(
            subject="another test post",
            mark_down="test mark down",
            html="test html",
            is_published=False,
            author=self.test_author,
        ).put()

        self.assertIsNotNone(memcache.get(Post._page_count_memcached_key))
开发者ID:tombatron,项目名称:tombatron-com,代码行数:18,代码来源:model_tests.py

示例2: _get_pagination_data

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_post_page_count [as 别名]
    def _get_pagination_data(self):
        page_number = int(self.request.route_kwargs.get('page_number', 1))
        number_of_pages = Post.get_post_page_count()

        if number_of_pages == 1:
            return {}

        pagination_data = {
            'prev_page_active': (page_number > 1),
            'prev_page':
                get_route('home_by_page', page_number = (page_number - 1))
                    if (page_number > 1) else '#',
            'next_page_active': (page_number < number_of_pages),
            'next_page':
                get_route('home_by_page', page_number = (page_number + 1))
                    if (page_number < number_of_pages) else '#',
            'pages': []
        }

        for i in range(1, number_of_pages + 1):
            pagination_data['pages'].append({
                'active': (i == page_number),
                'number': i,
                'url': get_route('home_by_page', page_number=i)
            })

        return pagination_data
开发者ID:tombatron,项目名称:tombatron-com,代码行数:29,代码来源:controllers.py

示例3: test_getting_page_count_caches_value_in_memcache

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_post_page_count [as 别名]
    def test_getting_page_count_caches_value_in_memcache(self):
        self._create_test_posts()

        Post.get_post_page_count()

        self.assertIsNotNone(memcache.get(Post._page_count_memcached_key))
开发者ID:tombatron,项目名称:tombatron-com,代码行数:8,代码来源:model_tests.py

示例4: test_page_count_does_not_include_non_published_posts

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_post_page_count [as 别名]
    def test_page_count_does_not_include_non_published_posts(self):
        self._create_test_posts()
        self._create_test_non_published_posts()

        self.assertEqual(Post.get_post_page_count(), 2)
开发者ID:tombatron,项目名称:tombatron-com,代码行数:7,代码来源:model_tests.py

示例5: test_can_get_post_page_count

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_post_page_count [as 别名]
    def test_can_get_post_page_count(self):
        self._create_test_posts()

        self.assertEqual(configuration.POSTS_PER_PAGE, 10)
        self.assertEqual(Post.get_post_page_count(), 2)
开发者ID:tombatron,项目名称:tombatron-com,代码行数:7,代码来源:model_tests.py


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