Private and Shared Tcl Libraries
Tcl libraries are initialized from both the private and shared Tcl directory specified for each virtual server.
- A private Tcl directory is specified with the Library configuration parameter. It defaults to /servers/servername/modules/tcl.
- A shared Tcl directory is specified with the SharedLibrary configuration parameter. It defaults to /modules/tcl and can be set to an empty string to disable shared libraries.
You can specify a private Tcl directory for each virtual server and a shared directory for any group of virtual servers. If you want a Tcl directory containing scripts to be shared by all of your virtual servers, for example, specify that same directory in the SharedLibrary parameter for all of the virtual servers (or leave the SharedLibrary parameter unset and put scripts in the default location).
Note that the private and shared directories you specify need not reside under the AOLserver installation directory. This allows you to keep user-defined scripts physically separate from the scripts supplied by AOLserver, yet still be able to maintain them through the AOLserver script maintenance interface (see Editing Shared and Private Scripts).
If a Tcl script with the same name resides in both the private Tcl directory and the shared Tcl directory for a virtual server, the script in the private Tcl directory is used. This feature allows you to copy shared scripts to a private directory for small modifications specific to that virtual server.
Tcl Script Order of Evaluation
At server startup time, Tcl initialization is performed in the following steps for each virtual server:
- If a private Tcl directory is specified, the
init.tcl
file in that directory is sourced first (if it exists), and then all the remaining .tcl
files are sourced alphabetically.
- If a shared Tcl directory is specified, the
init.tcl
file in that directory is sourced first (if it exists and if an init.tcl file does not also exist in the private Tcl directory). Then all .tcl
files that are not also in the private Tcl directory are sourced alphabetically.
- For each module (including any Tcl-only modules as described on Tcl-only Modules) in the virtual server:
- If a private Tcl directory is specified, the
init.tcl
file in the module-name subdirectory of the private directory is sourced first (if it exists), and then all the remaining .tcl
files are sourced alphabetically.
- If a shared Tcl directory is specified, the
init.tcl
file in the module-name subdirectory is sourced first (if it exists and if an init.tcl file does not also exist in the private Tcl directory). Then all .tcl
files that are not also in the private Tcl directory are sourced alphabetically.
Editing Shared and Private Scripts
The Tcl administration pages support editing shared and private scripts, and copying shared scripts to the private area. Follow the Tcl Scripting link on the server administration page (/NS/Admin). The relevant options on the Tcl Scripting page are:
- View/Edit Private Script Files: If you follow this link, a page is displayed that lists all the scripts and script directories in the private Tcl directory for the current virtual server. You can follow a link to a script to view or edit it, or you can follow a link to a directory to see the scripts in the directory, which you can then view or edit.
- You also have the option to create a new script in the private Tcl directory or create a new subdirectory in the private Tcl directory.
- View/Edit Shared Script Files: If you follow this link, a page is displayed that lists all the scripts and script directories in the shared Tcl directory. You can follow a link to a script to view or edit it, or you can follow a link to a directory to see the scripts in the directory, which you can then view or edit. For example:
- If you follow the link to a script, you can click the Copy to Private button to copy the script to the private Tcl directory so you can make modifications to it for a specific virtual server.
- You also have the option to create a new script in the shared Tcl directory or create a new subdirectory in the shared Tcl directory.