Index: openacs-4/packages/acs-tcl/tcl/deprecated-utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/deprecated-utilities-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/acs-tcl/tcl/deprecated-utilities-procs.tcl 7 Aug 2017 23:47:59 -0000 1.10 +++ openacs-4/packages/acs-tcl/tcl/deprecated-utilities-procs.tcl 10 Dec 2017 15:15:45 -0000 1.11 @@ -178,6 +178,68 @@ ad_proc {*}$args } +# +# GN: maybe this function was useful for ancient versions of Tcl, but +# unless i oversee something, it does not make any sense. The comment +# argues, that "return -code ..." ignores the error code, but then the +# function uses "return -code ..." to fix this... +# +ad_proc -deprecated ad_return { args } { + + Works like the "return" Tcl command, with one difference. Where + "return" will always return TCL_RETURN, regardless of the -code + switch this way, by burying it inside a proc, the proc will return + the code you specify. + +

+ + Why? Because "return" only sets the "returnCode" attribute of the + interpreter object, which the function actually interpreting the + procedure then reads and uses as the return code of the procedure. + This proc adds just that level of processing to the statement. + +

+ + When is that useful or necessary? Here: + +

+    set errno [catch {
+        return -code error "Boo!"
+    } error]
+    
+ + In this case, errno will always contain 2 (TCL_RETURN). + If you use ad_return instead, it'll contain what you wanted, namely + 1 (TCL_ERROR). + +} { + return {*}$args +} + +ad_proc -private -deprecated rp_handle_adp_request {} { + + Handles a request for an .adp file. + + @see adp_parse_ad_conn_file + +} { + doc_init + + set adp [ns_adp_parse -file [ad_conn file]] + + if { [doc_exists_p] } { + doc_set_property body $adp + doc_serve_document + } else { + set content_type [ns_set iget [ad_conn outputheaders] "content-type"] + if { $content_type eq "" } { + set content_type "text/html" + } + doc_return 200 $content_type $adp + } +} + + # Local variables: # mode: tcl # tcl-indent-level: 4