Пример #1
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, for_action=True)
    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, for_action=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
Пример #2
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBChange.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = ChangeOp
     return cp
Пример #3
0
 def __init__(self, *args, **kwargs):
     DBChange.__init__(self, *args, **kwargs)
Пример #4
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBChange.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = ChangeOp
     return cp
Пример #5
0
 def __init__(self, *args, **kwargs):
     DBChange.__init__(self, *args, **kwargs)