Hi,
  I'm moving my websites from Tclhttpd to Apache/Rivet. They are
all written using my Tcl-On-Track web framework.

  Part of reworking Tcl-On-Track to run under Rivet is implementing
Direct_Url.

  For those who don't use tclhttpd, Direct_Url is a mechanism to
allow a request like http://www.example.com/myProc to evaluate a
Tcl procedure "myProc" instead of throwing a 404 error. It's kind of
like a CGI script, but the procedure can be defined outside the
web data file hierarchy.

  The big issue is that Apache does not identify myProc as a legit URL,
since there's no file or folder named myProc. This generates a 404 error
before the Rivet subsystem gets ahold of it.

  I've come up with three hacks that work. I dislike two of them
intensely, dislike the last only a little.

  First the two that I don't like at all:

  1) Use ErrorDocument command:
     ErrorDocument 404 "/rivet/error.tcl"
     
     The error.tcl file checks to see if a handler has been
     assigned to the site, and evaluates that handler if it
     exists.
     
     I dislike this because it requires a folder named 
     $DocumentRoot/rivet/, and I'd really like to put all the
     TclOnTrack code in the /rivet/packages/tclOnTrack folder,
     not require an extra folder for each virtual host.

  2) Use mod_rewrite
     A definition like this in httpd.conf will send the error
     to /rivet/error.rvt

<VirtualHost *:80>
  DocumentRoot "/usr/local/www/apache24/data/blackpine"
RewriteEngine On
LogLevel mod_rewrite.c:trace8

RewriteCond /usr/local/www/apache24/data/blackpine/%{REQUEST_FILENAME} !-f
RewriteCond /usr/local/www/apache24/data/blackpine/%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /rivet/error.rvt [PT,L,QSA]
</VirtualHost *:80>

     Again, this requires that /usr/local/www/apache24/data/blackpine/rivet/
     exists.
     
     Variations of
RewriteRule ^(.*)$ /usr/local/lib/rivet/packages/tclOnTrack/error.rvt [PT,L,QSA]
RewriteRule ^(.*)$ /../../../rivet/packages/tclOnTrack/error.rvt [PT,L,QSA]

     Generate errors for trying to access a URL above DOCUMENT_ROOT. 

  3) Add a new suffix and type for Direct_Url

  Finally, the hack that I dislike the least.
    Add these lines to httpd.conf

RivetServerConf RequestHandler  
"/usr/local/lib/rivet/packages/tclOnTrack/requestApp.tcl"
AddType application/x-httpd-rivet .du

    The requestApp.tcl script is very much like the standard request
    handler except that it also looks for a procedure registered with the
    Direct_Url command.
    
    I'm not thrilled with this solution because I'm not thrilled with a 
    "magic" suffix for the Direct_Url procedures, but I can live with that.
    
And, Finally-Finally, if anyone has a better suggestion than these hacks, I'm
all ears. At this point my Tcl-On-Track port if minimally functional. I need to
get a couple more features ported, and clean up a lot of exploratory code before
I release it.

  My thanks to everyone who has put so much effort into Rivet.
  
  Clif
-- 
... Clif Flynt ... http://www.cflynt.com ... [email protected] ....
. Tcl/Tk: A Developer's Guide (4'th edition) - Morgan Kauffman  .
.............. Promised Rewards - Dark Myth Press ...............
.......... 5 Minutes in Hotel Stormcove - Atthis Arts ...........
.........  Unidentified Funny Objects, #7, #8, #9, #10  .........






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

Reply via email to