Exemple #1
0
    def get(self):
        page = int(self.get_argument('page', 1))
        per_page = int(self.get_argument('per_page', 20))

        pagination = yield gen.maybe_future(Comment.page_list(page, per_page))
        comments = list()
        for comment in pagination.items:
            info = yield gen.maybe_future(_comment_info(None, comment))
            comments.append(info)
        result = {
            'page': page,
            'pages': pagination.pages,
            'has_prev': pagination.has_prev,
            'has_next': pagination.has_next,
            'total': pagination.total,
            'comments': comments,
        }
        raise gen.Return(result)