human
Complete this python program:
def commit_on_success(using=None):
assistant
#Here is the Python program you requested.

    """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.
    """
    warnings.warn('commit_on_success    is    deprecated    in    favor    of    atomic.', PendingDeprecationWarning, stacklevel=2)
    def entering(using):
        enter_transaction_management(using=using)
    def exiting(exc_type, using):
        try:
            if (exc_type is not None):
                if is_dirty(using=using):
                    rollback(using=using)
            elif is_dirty(using=using):
                try:
                    commit(using=using)
                except:
                    rollback(using=using)
                    raise
        finally:
            leave_transaction_management(using=using)
    return _transaction_func(entering, exiting, using)