Tcl Web Application Framework

Framework for Simplifying Writing and Supporting Web Applications in Tcl

The Tcl Web Application Framework helps simplify writing Web applications in the Tool Command Language (Tcl). It provides the features that form the basis for writing an application, such as sessions, users, privilege separation, and an abstract database interface. It is currently under development, but stable for production use.

It is written in such a way that applications can integrate into the framework without having to modify the framework itself, making upgrading the framework without breaking the application possible.

Feedback and suggestions are appreciated as this project matures.

Using it with RivetCGI

The Tcl Web Application Framework requires a Rivet implementation. Unfortunately "mod_rivet" only works on Apache (and for a long time only worked on Apache 1.x) and does not change user IDs (as with "suexec" and "su_php") from the web server user ID.

To address this I've implemented a stand-alone Rivet implementation called RivetCGI. RivetCGI supports being run as a CGI under any existing HTTP server, or converting a directory tree into a Starkit (single file Tcl script that represents an archive of files and directories as a virtual filesystem within Tcl) and acting as a standalone server (or standalone CGI on any web server).

This last option is especially useful when used with the Tcl Web Application Framework, since you can create a single executable that represents your application and is a standalone web server.

How does it work ?

There are several pieces that need to fit together to make your application work:

  1. The Tcl Web Application Framework;
  2. RivetCGI;
  3. A Tclkit for the platform that you are building the Starkit on; and
  4. Optionally, a Tclkit for the platform that you wish to create a standalone executable for that does not require Tcl

Once you have all these pieces, you can use "bin/rivet2starkit" from RivetCGI with the arguments of the Tclkit, your kit-to-be-created, and the path to the Tcl Web Application Framework. After that, if you desire, you can convert the Starkit into a [Starpack] for any platform.

Walk me through it!

  1. Create an "archive" directory for tarballs
    1. $ mkdir archive
    2. $ cd archive/
  2. Download the latest Tcl Web Application Framework tarball [1] into the archive directory
    1. $ wget
  3. Download the latest RivetCGI tarball [2]
    1. $ wget
  4. Download Tclkits
    1. For your platform:
      1. $ wget -O tclkit
      2. $ chmod +x tclkit
    2. (Optional) For your run-time platforms:
      1. $ wget -O tclkit-win32
  5. Extract the archives
    1. $ tar -xf webapp-0.3.32.tar.gz
    2. $ tar -xf rivetcgi-
  6. Configure the Tcl Web Application Framework
    1. $ cd webapp-0.3.32
    2. $ ../tclkit setup.tcl
    3. Type of DB (mysql, mk4, sqlite): mk4
    4. Please enter a username: root
    5. Please enter a password: secret
    6. DB Filename:
    7. Database relative to index.rvt (Normal) or executable (Starkit) (y/N): y
    8. *** SECURITY WARNING ***
    9. Please ensure that the database file ("") is not
    10. accessible via HTTP (this usually does not affect RivetCGI).
    11. *** SECURITY WARNING ***
    12. root = b-49e71a67-7124c024-4e02d0726376861869c0
    13. anonymous = b-17939e23-7124d033-4e02d0725c7317ec69c0
    14. $ mv ../../
    15. $ cd ../
  7. Create your application
    1. $ cd ../
    2. $ mkdir myapp
    3. ... more to come...
  8. Convert your application and the Tcl Web Application framework into a Starkit
    1. $ archive/rivetcgi- "$(pwd)/archive/tclkit" myapp.kit archive/webapp-0.3.32 myapp:local
  9. Test it out:
    1. $ archive/tclkit myapp.kit --server --port 8080 --foreground yes --accesslog - --errorlog -
    2. Visit: http://localhost:8080/ in your web browser
  10. (Optional) Convert to a standalone executable:
    1. Download "sdx.kit"
      1. $ cd archive/
      2. $ wget
      3. $ cd ../
    2. Use "sdx.kit" to convert the Starkit "myapp.kit" into a [Starpack]
      1. $ archive/tclkit archive/sdx.kit unwrap myapp.kit
      2. $ archive/tclkit archive/sdx.kit wrap myapp.exe -runtime archive/tclkit-win32
    3. Test it out:
      1. $ wine ./myapp.exe --server --port 8080 --foreground yes --errorlog - --accesslog - --maxthreads 0