Hi Clif

by default Rivet handles every request running the request handler script in rivet/default_request_handler.tcl

The very first command of this script is

::Rivet::initialize_request

(located in rivet/init.tcl.in) which is simply

proc ::Rivet::initialize_request {} {
    catch { namespace delete ::request }

    namespace eval ::request {}

    proc ::request::global {args} {
        foreach arg $args {
            uplevel "::global ::request::$arg"
        }
    }
}

therefore in order to have rivet script (either .tcl or .rvt files) Tcl On Track should run this procedure before any code is evaluated and on every request

 -- Massimo


On 6/10/26 04:37, Clif Flynt wrote:
Hi,
   I'm trying to port Tcl On Track, the web framework I demonstrated at
the US Tcl Conference several years ago from TclHttpd to Rivet.

   I made heavy use of TclHttpd's Direct_Url construct in that code. I
think I've found a way to implement Direct_Url using a custom error
handler, but I'm running into a glitch accessing cookies.

   The line in httpd.conf is:

   ErrorDocument 404 "/rivet/error.tcl"

   The critical code in error.tcl is:

catch {
puts "<br>ERROR: INSTANCES OF ANNOUNCE '[info class instance announce]'<br>"
announce::show [string range $st 1 end]
} xx
puts "XX2: $xx<br>"

   This generates:
ERROR: INSTANCES OF ANNOUNCE ''

   And the error return shown later in this massive missive.

   Here's an excerpt of the code in my .tcl script that's invoked when
the error handler script calls announce::show.

puts "COOKIE: [lsort [namespace children ::]] <br>"
puts "COOKIE Proc: [lsort [info proc request::*]] <br>"
puts "COOKIE vars: [lsort [info vars request::*]] <br>"
puts "COOKIE cmds: [lsort [info commands request::*]] <br>"
catch {
     set sessionID [cookie get sessionID]
}
puts "ERROR $::errorInfo"

This generates the following output:

COOKIE: ::Rivet ::abstract ::announce ::auto_mkindex_parser ::base64 ::blog 
::centerLogo ::changePwd ::cmdline ::css ::debugPg ::def ::file ::fileutil 
::folders ::form ::form2 ::formCSS ::formH5 ::gpg ::html ::html8 ::iconStrip 
::itcl ::layout ::leftBelowLogo ::leftLogo ::login ::md5 ::msgcat ::ncgi 
::newuser ::oo ::pkg ::registration ::request ::rightLogo 
::rightLogoCenterMenuSlideShow ::rightLogoLowerMenu 
::rightLogoLowerMenuSlideShow ::rivet ::site ::story ::tagTweak ::tcl ::tdbc 
::track ::upperLower ::uri ::zlib
COOKIE Proc:
COOKIE vars:
COOKIE cmds:

ERROR: invalid command name "::request::global"
   while executing "::request::global RivetCookies"
     (procedure "cookie" line 26)
     invoked from within "cookie get sessionID"

XX2: invalid command name "::request::global"
invalid command name "::request::global" while executing
"::request::global RivetCookies"
     (procedure "cookie" line 26)
   invoked from within "cookie get sessionID"
     (procedure "track::getUserInfo" line 8)
   invoked from within "track::getUserInfo dbRtn"
     (procedure "site::top" line 19)
   invoked from within "site::top -title $path"
     (procedure "announce::show" line 62)
   invoked from within "announce::show [string range $st 1 end]"

...

   I'm guessing that the fact that I'm never invoking a .rvt script
is causing parts of Rivet to not be initialized.

   I tried invoking a rivet script
   ErrorDocument 404 "/rivet/error.rvt"

   with the original file's data enclosed inside <? ... ?>.
The behavior was the same as using the .tcl extension. Another concern is that the [info class instance announce] command
returns an empty string, though an announce object was created on the
page that tried to invoke the Direct_Url look-alike.
Is this a result of Apache giving me a new interpreter for each
page that gets loaded?




   I'm using BSD, wish8.6 and Rivet from the BSD depository.
FreeBSD 15.0-RELEASE (GENERIC) releng/15.0-n280995-7aedc8de6446

   Thanks for any pointers or suggestions,
   Clif


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to