document.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Young 作者: shiyanhui 项目源码 文件源码
def get_comment_list(topic_id, skip=0, limit=None):
        cursor = TopicCommentDocument.find({
            'topic': DBRef(TopicDocument.meta['collection'], ObjectId(topic_id))
        }).sort([('comment_time', pymongo.ASCENDING)]).skip(skip)

        if limit is not None:
            cursor = cursor.limit(limit)

        comment_list = yield TopicCommentDocument.to_list(cursor)
        for i, comment in enumerate(comment_list):
            comment['floor'] = skip + 1 + i
            comment['author'] = yield UserDocument.translate_dbref(
                comment['author']
            )

            if 'replyeder' in comment:
                comment['replyeder'] = yield UserDocument.translate_dbref(
                    comment['replyeder']
                )

        raise gen.Return(comment_list)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号