human
Complete the below
def commit_on_success(func):

    ''''This decorator activates commit on response. This way, if the view function
    runs successfully, a commit is made.
if the viewfunc produces an exception,
    a rollback is made. This is one of the most common ways to do transaction
    control in web apps.'
    '''
 Write me a the Python program you requested?
assistant
#Here is the Python program you requested.
    def _commit_on_success(*args, **kw):
        try:
            enter_transaction_management()
            managed(True)
            try:
                res = func(*args, **kw)
            except Exception as e:
                if is_dirty():
                    rollback()
                raise
            else:
                if is_dirty():
                    commit()
            return res
        finally:
            leave_transaction_management()
    return _commit_on_success