Example #1
0
 def execute(self):
     self._actions.reverse()
     for action in self._actions:
         try:
             action()
         except Exception, e:
             log.error('Error while undoing action %s' % action, e)
Example #2
0
 def execute(self):
     self._actions.reverse()
     for action in self._actions:
         try:
             action()
         except Exception as e:
             log.error('Error while undoing action %s' % action, exc_info=True)
Example #3
0
 def execute(self):
     self._actions.reverse()
     for action in self._actions:
         try:
             action()
         except Exception as e:
             logger.error(f"Error while undoing action {action}",
                          exc_info=True)
Example #4
0
    def add_undo_action(self, action, requires_transaction=True):
        """Add an action to undo."""
        if self._current_transaction:
            self._current_transaction.add(action)
            self._action_executed()
        elif requires_transaction:
            undo_stack = list(self._undo_stack)
            redo_stack = list(self._redo_stack)

            try:
                with Transaction(self.event_manager):
                    action()
            finally:
                # Restore stacks and act like nothing happened
                self._redo_stack = redo_stack
                self._undo_stack = undo_stack

            raise NotInTransactionException(
                "Updating state outside of a transaction.")