Index: openacs-4/packages/cms/www/modules/items/custom/image/create-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/custom/image/create-1.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/custom/image/create-1.tcl 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/custom/image/create-1.tcl 25 May 2001 02:15:56 -0000 1.2 @@ -102,11 +102,11 @@ - set db [ns_db gethandle] - ns_ora dml $db "begin transaction" - - # create a new image item - set sql " + db_transaction { + + # create a new image item + + if { [catch {db_exec_plsql " begin :item_id := content_item.new( name => :name, @@ -117,70 +117,65 @@ creation_ip => :ip_address, relation_tag => :relation_tag ); - end;" + end;"} item_id] } { + ns_log notice "custom/image/create-1.tcl caught error - $errmsg" - if { [catch {ns_ora exec_plsql_bind $db $sql item_id} errmsg] } { - ns_log notice "custom/image/create-1.tcl caught error - $errmsg" - - # check for double click - query clicks onevalue " + # check for double click + template::query get_clicks clicks onevalue " select count(1) from cr_items where item_id = :item_id - " -db $db + " - ns_ora dml $db "abort transaction" - ns_db releasehandle $db + db_dml abort "abort transaction" - if { $clicks > 0 } { - # double click error - do nothing, forward to view the item - template::forward \ + if { $clicks > 0 } { + # double click error - do nothing, forward to view the item + template::forward \ "../../index?item_id=$item_id" - } else { - template::request::error new_item_error \ + } else { + template::request::error new_item_error \ "custom/image/create-1.tcl - while creating new $content_type item - $errmsg" - return - } - } + return + } + } - # create the revision - ns_ora exec_plsql_bind $db " + # create the revision + set revision_id [db_exec_plsql new_revision " begin - :revision_id := content_revision.new ( + :1 := content_revision.new ( item_id => :item_id, title => :title, description => :description, mime_type => :mime_type, creation_user => :user_id, creation_ip => :ip_address ); - end; - " revision_id + end;"] - # insert the extended attributes - ns_ora dml $db " + # insert the extended attributes + db_dml insert_images " insert into images ( image_id, width, height ) values ( :revision_id, :width, :height )" - # upload the image - ns_ora blob_dml_file $db " + # upload the image + db_dml insert_revisions " update cr_revisions set content = empty_blob() where revision_id = $revision_id - returning content into :1" $tmp_filename + returning content into :1" -blob_files $tmp_filename - ns_ora dml $db "end transaction" - ns_db releasehandle $db + } # flush the paginator cache cms_folder::flush sitemap $parent_id template::forward "../../index?item_id=$item_id" -} \ No newline at end of file +}