Beispiel #1
0
def create_add_op_chain(object, parent=(None, None)):
    opChain = []
    object = copy.copy(object)
    adds = object.db_children(parent, True)
    adds.reverse()
    for (obj, parentType, parentId) in adds:
        op = DBAdd(
            id=-1,
            what=obj.vtType,
            objectId=obj.db_id,
            parentObjType=parentType,
            parentObjId=parentId,
            data=obj,
        )
        opChain.append(op)
    return opChain
Beispiel #2
0
def create_change_op_chain(old_obj, new_obj, parent=(None, None)):
    opChain = []
    new_obj = copy.copy(new_obj)
    deletes = old_obj.db_children(parent)
    deletes.pop()
    for (obj, parentType, parentId) in deletes:
        op = DBDelete(
            id=-1,
            what=obj.vtType,
            objectId=obj.db_id,
            parentObjType=parentType,
            parentObjId=parentId,
        )
        opChain.append(op)

    adds = new_obj.db_children(parent, True)
    (obj, parentType, parentId) = adds.pop()
    op = DBChange(
        id=-1,
        what=obj.vtType,
        oldObjId=old_obj.db_id,
        newObjId=obj.db_id,
        parentObjType=parentType,
        parentObjId=parentId,
        data=new_obj,
    )
    opChain.append(op)

    adds.reverse()
    for (obj, parentType, parentId) in adds:
        op = DBAdd(
            id=-1,
            what=obj.vtType,
            objectId=obj.db_id,
            parentObjType=parentType,
            parentObjId=parentId,
            data=obj,
        )
    return opChain
Beispiel #3
0
def create_copy_op_chain(object, parent=(None, None), id_scope=None):
    opChain = []
    id_remap = {}
    object = copy.copy(object)

    adds = object.db_children(parent, True)
    adds.reverse()
    for (obj, parentType, parentId) in adds:
        if parentId is not None:
            parentId = id_remap[(parentType, parentId)]
        new_id = id_scope.getNewId(obj.vtType)
        id_remap[(obj.vtType, obj.db_id)] = new_id
        obj.db_id = new_id
        op = DBAdd(
            id=-1,
            what=obj.vtType,
            objectId=obj.db_id,
            parentObjType=parentType,
            parentObjId=parentId,
            data=obj,
        )
        opChain.append(op)
    return opChain
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBAdd.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = AddOp
     return cp
 def __init__(self, *args, **kwargs):
     DBAdd.__init__(self, *args, **kwargs)
Beispiel #6
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBAdd.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = AddOp
     return cp
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     DBAdd.__init__(self, *args, **kwargs)