Posted to tcl by kbk at Thu Jun 12 02:25:45 GMT 2008view pretty

method transaction {script} {
	my begintransaction
	set status [catch {uplevel 1 $script} result options]
	switch -exact -- $status {
	    0 {
		my commit
	    }
	    2 - 3 - 4 {
		set options [dict merge {-level 1} $options[set options {}]]
		dict incr options -level
		my commit
	    }
	    default {
		my rollback
	    }
	}
	return -options $options $result
    }