Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     DBAction.__init__(self, *args, **kwargs)
     if self.timestep is None:
         self.timestep = -1
     if self.parent is None:
         self.parent = -1
     if self.user is None:
         self.user = ''
     if self.expand is None:
         self.expand = 0
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     DBAction.__init__(self, *args, **kwargs)
     if self.timestep is None:
         self.timestep = -1
     if self.parent is None:
         self.parent = -1
     if self.user is None:
         self.user = ''
     if self.expand is None:
         self.expand = 0
Ejemplo n.º 3
0
def create_action_from_ops(ops, simplify=False):
    if simplify:
        ops = simplify_ops(ops)

    action = DBAction(id=-1,
                      operations=ops)
    return action
Ejemplo n.º 4
0
def create_action(action_list):
    """create_action(action_list: list) -> DBAction
    where action_list is a list of tuples
     (
      type, 
      object, 
      new_obj=None,
      parent_type=None,
      parent_id=None,
    )
    Example: create_action([('add', module1), ('delete', connection2)])

    """
    ops = []
    for tuple in action_list:
        if tuple[0] == 'add' and len(tuple) >= 2:
            if len(tuple) >= 4:
                ops.extend(create_add_op_chain(tuple[1], (tuple[2], tuple[3])))
            else:
                ops.extend(create_add_op_chain(tuple[1]))
        elif tuple[0] == 'delete' and len(tuple) >= 2:
            if len(tuple) >= 4:
                ops.extend(create_delete_op_chain(tuple[1], 
                                                  (tuple[2], tuple[3])))
            else:
                ops.extend(create_delete_op_chain(tuple[1]))
        elif tuple[0] == 'change' and len(tuple) >= 3:
            if len(tuple) >= 5:
                ops.extend(create_change_op_chain(tuple[1], tuple[2],
                                                  (tuple[3], tuple[4])))
            else:
                ops.extend(create_change_op_chain(tuple[1], tuple[2]))
        else:
            msg = "unable to interpret action tuple " + tuple.__str__()
            raise ValueError(msg)
    action = DBAction(id=-1,
                      operations=ops)
    return action
Ejemplo n.º 5
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBAction.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = Action
     return cp
Ejemplo n.º 6
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBAction.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = Action
     return cp