Пример #1
0
def container_from_path(path):
    """
    Return container object from path, None if nothing found.
    """
    coll = Container.collection()
    dic = coll.find_one({"materialized_path": path})
    return Container.unserialize(dic) if dic is not None else None
Пример #2
0
def get_container(container_id):
    """
    Given container id, return container object.
    None if nothing found.
    """
    coll = Container.collection()
    dic = coll.find_one({"_id": coerce_bson_id(container_id)})
    return Container.unserialize(dic) if dic is not None else None
Пример #3
0
def child_containers(container_obj):
    """
    Get all child containers of a given container
    """
    child_container_dics = Container.collection().find({
        "parent_id": container_obj.obj_id() if container_obj is not None else None,
    })
    all_child_containers = [Container.unserialize(x) for x in child_container_dics]
    return all_child_containers
Пример #4
0
def remove_container(container_id):
    coll = Container.collection()
    coll.remove({"_id": coerce_bson_id(container_id)})
Пример #5
0
def save_container(container_obj):
    col = Container.collection()
    id = col.save(container_obj.serialize())
    return id