本文整理汇总了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)))
示例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
示例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.")
示例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)
示例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)))
示例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)
示例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)