Beispiel #1
0
 def get(self, topic_id, *args, **kwargs):
     try:
         topic = PostTopic.get(PostTopic.str == topic_id)
     except PostTopic.DoesNotExist:
         self.redirect("/static/404.html")
         return
     current_page = get_cleaned_query_data(self, [
         'page',
     ], blank=True)['page']
     if current_page:
         current_page = int(current_page)
         if current_page < 1:
             self.redirect("/static/404.html")
             return
         posts, page_number_limit = Post.list_by_topic(
             topic, page_number=current_page)
     else:
         current_page = 1
         posts, page_number_limit = Post.list_by_topic(topic)
     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=topic,
                 pages=pages,
                 pages_prefix_url='/topic/' + topic.str + '?page=')
Beispiel #2
0
    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=')
Beispiel #3
0
def get_topic_index_info(topic_id, current_page, page_limit=config.default_page_limit):
    try:
        topic = PostTopic.get(PostTopic.str == topic_id)
    except PostTopic.DoesNotExist:
        return None
    current_page = get_page_number(current_page)
    posts, page_number_limit = Post.list_by_topic(topic, page_number=current_page)
    top_posts, _ = Post.list_top()
    pages = get_page_nav(current_page, page_number_limit, page_limit)
    return topic, posts, top_posts, pages
Beispiel #4
0
def get_topic_index_info(topic_id,
                         current_page,
                         page_limit=config.default_page_limit):
    try:
        topic = PostTopic.get(PostTopic.str == topic_id)
    except PostTopic.DoesNotExist:
        return None
    current_page = get_page_number(current_page)
    posts, page_number_limit = Post.list_by_topic(topic,
                                                  page_number=current_page)
    top_posts, _ = Post.list_top()
    pages = get_page_nav(current_page, page_number_limit, page_limit)
    return topic, posts, top_posts, pages
Beispiel #5
0
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
Beispiel #6
0
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