def get(self, *args, **kwargs): # profiling 性能分析 # from profiling.tracing import TracingProfiler # # # profile your program. # profiler = TracingProfiler() # profiler.start() current_page = get_cleaned_query_data(self, [ 'page', ], blank=True)['page'] current_page = get_page_number(current_page) posts, page_number_limit = Post.list_recently(page_number=current_page) top_posts, _ = Post.list_top() pages = get_page_nav(current_page, page_number_limit, config.default_page_limit) self.render('index/index.html', posts=posts, top_posts=top_posts, topic_category_cache=topic_category_cache, hot_post_cache=hot_post_cache, systatus=system_status_cache, current_topic=None, pages=pages, pages_prefix_url='/?page=')
def get_index_info(current_page, page_limit=config.default_page_limit): current_page = get_page_number(current_page) posts, page_number_limit = Post.list_recently(page_number=current_page) top_posts, _ = Post.list_top() pages = get_page_nav(current_page, page_number_limit, page_limit) return posts, top_posts, pages