Tcl Web Application Framework
Framework for Simplifying Writing and Supporting Web Applications in Tcl
- Documentation: http://www.rkeene.org/projects/webapp/webapp.pdf
- Source: http://www.rkeene.org/devel/webapp-0.3.32.tar.gz
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:
- The Tcl Web Application Framework;
- RivetCGI;
- A Tclkit for the platform that you are building the Starkit on; and
- 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!
- Create an "archive" directory for tarballs
- $ mkdir archive
- $ cd archive/
- Download the latest Tcl Web Application Framework tarball [1] into the archive directory
- Download the latest RivetCGI tarball [2]
- Download Tclkits
- For your platform:
- $ wget -O tclkit http://www.rkeene.org/devel/kitcreator/kitbuild/0.6.1/tclkit-8.5.10-linux-i686
- $ chmod +x tclkit
- (Optional) For your run-time platforms:
- For your platform:
- Extract the archives
- $ tar -xf webapp-0.3.32.tar.gz
- $ tar -xf rivetcgi-0.5.0.3063.tar.gz
- Configure the Tcl Web Application Framework
- $ cd webapp-0.3.32
- $ ../tclkit setup.tcl
- Type of DB (mysql, mk4, sqlite): mk4
- Please enter a username: root
- Please enter a password: secret
- DB Filename: database.mk
- Database relative to index.rvt (Normal) or executable (Starkit) (y/N): y
- *** SECURITY WARNING ***
- Please ensure that the database file ("database.mk") is not
- accessible via HTTP (this usually does not affect RivetCGI).
- *** SECURITY WARNING ***
- root = b-49e71a67-7124c024-4e02d0726376861869c0
- anonymous = b-17939e23-7124d033-4e02d0725c7317ec69c0
- $ mv database.mk ../../
- $ cd ../
- Create your application
- $ cd ../
- $ mkdir myapp
- ... more to come...
- Convert your application and the Tcl Web Application framework into a Starkit
- $ archive/rivetcgi-0.5.0.3063/bin/rivet2starkit "$(pwd)/archive/tclkit" myapp.kit archive/webapp-0.3.32 myapp:local
- Test it out:
- $ archive/tclkit myapp.kit --server --port 8080 --foreground yes --accesslog - --errorlog -
- Visit: http://localhost:8080/ in your web browser
- (Optional) Convert to a standalone executable:
- Download "sdx.kit"
- $ cd archive/
- $ wget http://equi4.com/pub/sk/sdx.kit
- $ cd ../
- Use "sdx.kit" to convert the Starkit "myapp.kit" into a [Starpack]
- $ archive/tclkit archive/sdx.kit unwrap myapp.kit
- $ archive/tclkit archive/sdx.kit wrap myapp.exe -runtime archive/tclkit-win32
- Test it out:
- $ wine ./myapp.exe --server --port 8080 --foreground yes --errorlog - --accesslog - --maxthreads 0
- Download "sdx.kit"