def execCommandList(model_object, commands, desc=None, use_undostack=True):
    """
    This is a wrapper for performing QUndoCommands, meant to ensure
    uniform handling of the undoStack and macro descriptions.

    When using the undoStack, commands are pushed onto self.undoStack()
    as part of a macro with description desc. Otherwise, command redo
    methods are called directly.
    """
    if use_undostack:
        us = model_object.undoStack()
        us.beginMacro(desc)
        for c in commands:
            us.push(c)
        us.endMacro()
    else:
        for c in commands:
            c.redo()
