()
return res
return first 10 comments of the paper with pid
return first 10 comments of the paper with pid
return first 10 comments of the paper with pid
def get_comment():
    """ return first 10 comments of the paper with pid """
    try:
        pid = long(request.values.get('pid'))
        page = int(request.values.get('page'))
    except Exception:
        return {'status': 'error',
                'reason': 'invalid request'}

    db = get_mongo('paper')
    res = db.find_one({'_id': pid}, {'comments': {'$slice': [page*10, 10]}, 'cmt_count': 1})
    log_info("Return 10 comments of paper {0}".format(pid))

    if res is None:
        return {}
    return res
def get_comment ( ) : try : pid = long ( request . values . get ( 'pid' ) ) page = int ( request . values . get ( 'page' ) ) except Exception : return { 'status' : 'error' , 'reason' : 'invalid request' } db = get_mongo ( 'paper' ) res = db . find_one ( { '_id' : pid } , { 'comments' : { '$slice' : [ page * 10 , 10 ] } , 'cmt_count' : 1 } ) log_info ( "Return 10 comments of paper {0}" . format ( pid ) ) if res is None : return { } return res