Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -r1.39 -r1.40 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 9 Jan 2004 09:11:59 -0000 1.39 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 9 Jan 2004 09:38:25 -0000 1.40 @@ -771,32 +771,35 @@ upvar 1 $array row set array row } - set workflow_id [workflow::clone \ - -workflow_id $workflow_id \ - -package_key $package_key \ - -object_id $object_id \ - -array $array \ - -workflow_handler simulation::template] - - # Special for simulation template: - # If there is no initial-action, we create one now - set initial_action_id [workflow::get_element -workflow_id $workflow_id -element initial_action_id] - if { [empty_string_p $initial_action_id] } { + db_transaction { + set workflow_id [workflow::clone \ + -workflow_id $workflow_id \ + -package_key $package_key \ + -object_id $object_id \ + -array $array \ + -workflow_handler simulation::template] - set action_row(pretty_name) "Start" - set action_row(pretty_past_tense) "Started" - set action_row(initial_action_p) "t" - - set states [workflow::fsm::get_states -workflow_id $workflow_id] + # Special for simulation template: + # If there is no initial-action, we create one now - # We use the first state as the initial state - set action_row(new_state_id) [lindex $states 0] - - workflow::action::fsm::edit \ - -operation "insert" \ - -array action_row \ - -workflow_id $workflow_id + set initial_action_id [workflow::get_element -workflow_id $workflow_id -element initial_action_id] + if { [empty_string_p $initial_action_id] } { + + set action_row(pretty_name) "Start" + set action_row(pretty_past_tense) "Started" + set action_row(initial_action_p) "t" + + set states [workflow::fsm::get_states -workflow_id $workflow_id] + + # We use the first state as the initial state + set action_row(new_state_id) [lindex $states 0] + + workflow::action::fsm::edit \ + -operation "insert" \ + -array action_row \ + -workflow_id $workflow_id + } } return $workflow_id