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


Python Post.get_posts_by_page方法代码示例

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


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

示例1: test_new_non_published_post_does_not_purge_cached_pages

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

        Post.get_posts_by_page(2)

        self.assertIsNotNone(memcache.get(Post._page_memcached_key_prefix % (date.today(), 2)))

        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_memcached_key_prefix % (date.today(), 2)))
开发者ID:tombatron,项目名称:tombatron-com,代码行数:18,代码来源:model_tests.py

示例2: _get_data_for_list

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

        try:
            posts = Post.get_posts_by_page(page_number)
        except InvalidPageSelectedException:
            self.abort(404)

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

示例3: test_getting_posts_by_page_does_not_include_future_posts

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

        # Create a post for the future.
        Post(
            subject="this post shouldn't show up.",
            mark_down="test mark down",
            html="test html",
            is_published=True,
            author=self.test_author,
            post_date=datetime.today() + timedelta(days=1),
        ).put()

        posts = Post.get_posts_by_page(1)

        self.assertFalse(posts[0].subject == "this post shouldn't show up.")
开发者ID:tombatron,项目名称:tombatron-com,代码行数:18,代码来源:model_tests.py

示例4: test_exception_if_invalid_page_number_is_requested

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

        with self.assertRaises(InvalidPageSelectedException):
            Post.get_posts_by_page(10)
开发者ID:tombatron,项目名称:tombatron-com,代码行数:7,代码来源:model_tests.py

示例5: test_getting_posts_by_page_caches_in_memcached

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

        Post.get_posts_by_page(2)

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

示例6: test_getting_posts_by_page_does_not_include_non_published_posts

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

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

示例7: test_can_get_posts_by_page

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

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


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