[ Previous ] [ Contents ] [ Index ] [ Next ]

What Are Tcl Libraries?

A Tcl library is simply a directory containing Tcl scripts that are sourced at startup by a virtual server. You can create private libraries for individual virtual servers and public libraries that affect all or some of an installation's virtual servers.

Each Tcl file in a library often contains one or more calls to ns_register_proc, ns_schedule_proc, or ns_register_filter to bind a script to a specific URL or URL hierarchy, plus the Tcl scripts that will handle the URL(s). This example shows the ns_register_proc function being used to bind the Tcl procedure "hello" to handle a GET request for /example/hello, plus the "hello" procedure itself:

    ns_register_proc GET /example/hello hello
    
    proc hello {conn context} {
    	  ns_return $conn 200 text/plain "Hello World"
    }

Tcl libraries can also be created that contain no registration functions; they may just contain Tcl scripts that are called from ADPs.

When AOLserver processes a method/URL request, it checks to see if there is a Tcl script in the virtual server's private or shared library to handle the method and URL. A private Tcl script registered to handle a URL overrides a shared Tcl script registered to handle the same URL.

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.