def _doundo(self, finalaction, direction):

        if direction < 0:
            actionlog = \
                self._actionlog[finalaction + 1:self._curaction + 1][::-1]
        else:
            actionlog = self._actionlog[self._curaction:finalaction]

        # Uncomment this for debugging
#         print("curaction, finalaction, direction", \
#               self._curaction, finalaction, direction)
        for i in range(len(actionlog)):
            if actionlog['opcode'][i] != _op_to_code["MARK"]:
                # undo/redo the action
                if direction > 0:
                    # Uncomment this for debugging
#                     print("redo-->", \
#                           _code_to_op[actionlog['opcode'][i]],\
#                           actionlog['arg1'][i],\
#                           actionlog['arg2'][i])
                    undoredo.redo(self,
                                  # _code_to_op[actionlog['opcode'][i]],
                                  # The next is a workaround for python < 2.5
                                  _code_to_op[int(actionlog['opcode'][i])],
                                  actionlog['arg1'][i].decode('utf8'),
                                  actionlog['arg2'][i].decode('utf8'))
                else:
                    # Uncomment this for debugging
                    # print("undo-->", \
                    #       _code_to_op[actionlog['opcode'][i]],\
                    #       actionlog['arg1'][i].decode('utf8'),\
                    #       actionlog['arg2'][i].decode('utf8'))
                    undoredo.undo(self,
                                  # _code_to_op[actionlog['opcode'][i]],
                                  # The next is a workaround for python < 2.5
                                  _code_to_op[int(actionlog['opcode'][i])],
                                  actionlog['arg1'][i].decode('utf8'),
                                  actionlog['arg2'][i].decode('utf8'))
            else:
                if direction > 0:
                    self._curmark = int(actionlog['arg1'][i])
                else:
                    self._curmark = int(actionlog['arg1'][i]) - 1
                    # Protection against negative marks
                    if self._curmark < 0:
                        self._curmark = 0
            self._curaction += direction
Encode message to the socket.io wire format.
dataset/ETHPy150Open PyTables/PyTables/tables/file.py/File._doundo--crossover with--dataset/ETHPy150Open mrjoes/tornadio/tornadio/proto.py/encode