Forum OpenACS Q&A: Server log errors

Collapse
Posted by Martin Elsman on
I think I have found a problem with the chat-index-page and many other pages in OpenACS and ACS. The problem has to do with the `-code return' option to the return tcl-command and appears when a user tries to access the chat-index-page without being logged in; in this case an error is reported in the server.log, although the registration page is served to the user, nicely.

Here is a small example-file that causes a server error:

  proc test {} {
      return -code return
  }
  ReturnHeaders
  ns_write "Hello..."
  set a [test]
  ns_write "...Goodbye"
If the call to test appears outside of brackets, no server error occurs! Does someone know which is the correct behavior?

In OpenACS, one problematic procedure that uses the `-code return' feature is ad_scope_authorize, which returns the user_id if the user is logged in and returns with `-code return' if the user is not logged in and registration is required. There are many files that use the ad_scope_authorize procedure and a fix to these files is to exchange lines of the form

  set user_id [ad_scope_authorize $db $scope registered 
               group_member none]
into
  ad_scope_authorize $db $scope registered group_member none
  set user_id [ad_verify_and_get_user_id]
which does the right thing; in particular, this solution works for ../chat/index.tcl.
Collapse
Posted by Martin Elsman on
I should note here that I'm running AOLserver/3.1+ad8 + OpenACS 3.2.4.
Collapse
Posted by Don Baccus on
well ...
set a test
is exactly the same as
set a "test"
in this case (quotes aren't required around literal strings that don't include spaces and other special characters).

This explains why the procedure isn't called when you remove the square brackets.

Exactly what server error are you getting?

Collapse
Posted by Martin Elsman on
The problematic thing is that when I edit the file above to read
  proc test {} {
      return -code return
  }
  ReturnHeaders
  ns_write "Hello..."
  test
  ns_write "...Goodbye"
then I don't get a server error!

According to the documentation of the return statement, I would not expect the original file to cause a server error - albeit it does. Here I show the original file again:

  proc test {} {
      return -code return
  }
  ReturnHeaders
  ns_write "Hello..."
  set a [test]
  ns_write "...Goodbye"
Comments are welcome!