How to add TWAPI extension under AOLserver

From AOLserver Wiki
Jump to navigation Jump to search

Caution: According to TWAPI's author "TWAPI has not been tested with multiple threads so you have to be careful to call it from only one thread within a process." [1]


  • TWAPI Extension [2] (Download the zip version e.g., where x.x.s is the major.minor version numbers)


Step 1. Download and unzip TWAPI Extract the downloaded file into AOLserver/servers/{yourserver}/modules/tcl. Now you should have directory named twapi under your server tcl modules directory e.g.


Step 2. Modify TWAPI pkgIndex.tcl file

Under this file find the line which says:

   package ifneeded twapi $twapi::version [list source [file join $dir twapi.tcl]]

and change it so that it looks like the following line:

   package ifneeded twapi $twapi::version [list source [file join [ns_library private twapi] twapi.tcl]]

Save your changes to pkgIndex.tcl.

Step 3. Configure AOLserver config file

In AOLserver config file look for following lines:

   # Modules to load
   ns_section "ns/server/${servername}/modules"

Under modules section toward the end add the following line:

   # Loading a Tcl module
   ns_param twapi	tcl

At this point configuration is complete and TWAPI will be loaded the next time server is started.

Additional Step 4. Testing

In order to test if twapi package can be loaded successfully into AOLserver. Create an empty adp file named twapi.adp or your own choice under your server pages directory. And Copy the following contents into this file:

   # twapi.adp
   if { [catch {package require twapi} msg] } {
   	ns_adp_puts "ERROR loading TWAPI package. ERRMSG:$msg"
   } else {
   	ns_adp_puts "TWAPI $msg loaded successfully";

Now save this file and fire up you browser and point it your AOLserver/twapi.adp

Category Documentation - Tutorials