示例#1
0
def get(comment_id):
    """
    Return the comment object given the id

    :param comment_id:
    """
    dic = Comment.collection().find_one({
        "_id": coerce_bson_id(comment_id)
    })
    return Comment.unserialize(dic) if dic is not None else None
示例#2
0
def get_all(obj_id, collection_name, limit=None):
    """
    Get all comments on a given object

    :param obj_id:
    :param collection_name:
    :param limit:
    """
    comments = Comment.collection().find({
        "obj_id": str(obj_id),
        "coll_name": collection_name
    }).sort("timestamp_utc", pymongo.DESCENDING)
    comment_obj_lis = [Comment.unserialize(x) for x in comments]
    return comment_obj_lis