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