Index: openacs-4/packages/cms/www/modules/items/template-register.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/template-register.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/template-register.tcl 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/template-register.tcl 24 May 2001 23:57:17 -0000 1.2 @@ -6,28 +6,24 @@ request set_param context -datatype keyword -set sql "begin content_item.register_template( - item_id => :item_id, - template_id => :template_id, - use_context => :context ); - end;" +db_transaction { -set db [template::begin_db_transaction] - -# check to make sure that no template is already registered -# to this item in this context -template::query second_template_p onevalue " + # check to make sure that no template is already registered + # to this item in this context + template::query second_template_p second_template_p onevalue " select count(1) from cr_item_template_map where use_context = :context and item_id = :item_id" -if { $second_template_p == 0 } { - if { [catch { template::query template_register dml $sql } err_msg] } { - ns_log notice "template-register.tcl got an error: $err_msg" - } + if { $second_template_p == 0 } { + if { [catch { template::query template_register dml "begin content_item.register_template( + item_id => :item_id, + template_id => :template_id, + use_context => :context ); + end;"} err_msg] } { + ns_log notice "template-register.tcl got an error: $err_msg" + } + } } -template::end_db_transaction -template::release_db_handle - forward "../items/index?item_id=$item_id&#templates"