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

  1. method transaction {script} {
  2. my begintransaction
  3. set status [catch {uplevel 1 $script} result options]
  4. switch -exact -- $status {
  5. 0 {
  6. my commit
  7. }
  8. 2 - 3 - 4 {
  9. set options [dict merge {-level 1} $options[set options {}]]
  10. dict incr options -level
  11. my commit
  12. }
  13. default {
  14. my rollback
  15. }
  16. }
  17. return -options $options $result
  18. }