Forum OpenACS Development: Problem over-loading ns_return

Request notifications

Collapse
Posted by Brian Fenton on
Hi all

this is happening to me with Naviserver on Windows with OpenACS 590. This is code that used work on AOLserver with an earlier version of OpenACS. Renaming and over-loading ns_return isn't working for me.

I have the put the following code in a package -init.tcl and restarted Naviserver.

ns_log Notice "BRIAN BRIAN info commands=[info commands ns_return]"
rename ns_return acs_return
ns_log Notice "BRIAN BRIAN acs_return info commands=[info commands acs_return], AND [info procs acs_return] PLUS commands=[info commands ns_return], AND [info procs ns_return]"
ns_log Notice "BRIAN BRIAN 1namespace which =[namespace which acs_return], AND [namespace which ns_return]"
proc ns_return { status mime_type content } {
ns_log Notice "BRIAN BRIAN 2namespace which =[namespace which acs_return], AND [namespace which ns_return]"
acs_return $status $mime_type $content
}
ns_log Notice "BRIAN BRIAN 3 body =[info body ns_return] AND [namespace which ns_return]"

The error log has the following output after restarting and trying to access a page:
[07/Apr/2017:09:27:34][3288.1764][-main-] Notice: BRIAN BRIAN info commands=ns_return
[07/Apr/2017:09:27:34][3288.1764][-main-] Notice: BRIAN BRIAN acs_return info commands=acs_return, AND PLUS commands=, AND
[07/Apr/2017:09:27:34][3288.1764][-main-] Notice: BRIAN BRIAN 1namespace which =::acs_return, AND
[07/Apr/2017:09:27:34][3288.1764][-main-] Notice: BRIAN BRIAN 3 body =
ns_log Notice "BRIAN BRIAN 2namespace which =[namespace which acs_return], AND [namespace which ns_return]"
acs_return $status $mime_type $content
AND ::ns_return
[07/Apr/2017:09:29:15][3288.14c4][-conn:openacs:0-] Notice: BRIAN BRIAN 2namespace which =, AND ::ns_return
[07/Apr/2017:09:29:15][3288.14c4][-conn:openacs:0-] Notice: BRIAN BRIAN 2namespace which =, AND ::ns_return
[07/Apr/2017:09:29:15][3288.14c4][-conn:openacs:0-] Error: GET /register/, PeerAddress: 127.0.0.1
invalid command name "acs_return"
while executing
"acs_return $status $mime_type $content"
(procedure "ns_return" line 3)
invoked from within
"ns_return 500 text/html $rendered_page"
(procedure "::nsf::procs::rp_report_error" line 42)
invoked from within
"rp_report_error"
(procedure "rp_handler" line 147)
invoked from within
"rp_handler"
while executing callback
ns:tclrequest rp_handler
(context: request proc)

What is interesting is that the "BRIAN BRIAN 3" and the "BRIAN BRIAN 2namespace" log entries indicates that the overload seems to have worked during server start, but then later it fails when it can no longer find acs_return.
I have tried using the :: namespace but get the same result.

Any suggestions?
thanks
Brian

Collapse
Posted by Gustaf Neumann on
naviserver makes no attempt to preserve "renames" in the blueprint, since renames are destructive, and it is practically impossible to determine where during loading of the blueprint there is the right place to rename a command.

Why are you trying to rename "ns_return"?

Collapse
Posted by Brian Fenton on
Hi Gustaf

this is some legacy code that was used to hide any "ugly" errors from users. The guy who wrote it decided that replacing ns_return, ns_returnnotfound, ns_returnerror and ad_return_error was preferable to using the config.tcl redirects (in ns/server/${server}/redirects). I think the reason he did this (but I can't really remember to be honest) was that the redirects were no always reliable back in those days.

Seeing as rename is no longer available in this case, it looks like I'll be using the redirects!

thank for the explanation.
Brian