def get_comment_list(share_id, skip=0, limit=None):
cursor = ShareCommentDocument.find({
'share': DBRef(
ShareDocument.meta['collection'],
ObjectId(share_id)
)
}).sort([('comment_time', pymongo.ASCENDING)]).skip(skip)
if limit is not None:
cursor = cursor.limit(limit)
comment_list = yield ShareCommentDocument.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)
评论列表
文章目录