I refer in this post to AOLserver branch nsd_v3_r3_p0 at SourceForge
which has some bugfixes to TCL namespace mechanism (when compared to
AOLserver 3.2). For details see:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/aolserver/aolserver/tcl/Attic/namespace.tcl?only_with_tag=nsd_v3_r3_p0&hideattic=0

I would like to know if I can safely use TCL namespaces in AOLserver. I've
found voices that "Tcl namespaces were screwy in AOLserver3.2 and earlier
versions. Namespace variables do not get cleared between requests within
the same thread." See:
http://www.arsdigita.com/bboard/q-and-a-fetch-msg?msg%5fid=000Jrt&topic%5fid=175&topic=ACS%20Design

Is it fixed in nsd_v3_r3_p branch? Can someone explain that.

I've also encountered some problems when using TCL packages and
namespaces. I would like my experiences to be discussed and changes
proposed by me incorporated into AOLserver if they are appropriate.

1. TCL library

In AOLserver command [info library] returns error "no library has been
specified for Tcl". To make it work I manually set tcl_library like
this:

set tcl_library [ns_info home]/lib/tcl8.3

I think it should be set by AOLserver based on value given in
build/install process.

To use procs from TCL library (ex. parray) I have to source it
manually as described in
http://dev.scriptics.com/man/tcl8.3.2/TclCmd/library.htm

source [file join [info library] init.tcl]

Tclsh does it automatically so maybe AOLserver should do the
same. What do you think?

2. Using Tcllib

Tcllib is a collection of useful utility modules for Tcl

http://dev.scriptics.com/software/tcllib/

I needed base64 and pop3 packages from that library. I've installed it
in default dir /usr/local/lib/tcllib0.8/

To use it I added something like that to AOLserver private tcl library

package require base64 ; # that worked
package require pop3   ; # that failed

Second command failed because of bug in AOLserver TCL interpreter init
script. When TCL package defines in its namespace proc 'list' (as
pop3::list does) the code in $NSHOME/modules/tcl/namespace.tcl
fails. It uses proc 'list' in namespace eval block which calls locally
defined proc not the global 'list' command. I fixed that by using
'::list' instead of 'list' in $NSHOME/modules/tcl/namespace.tcl. I
suspect there are possible problems with other commands redefined by
namespace so code in namespace.tcl sould be revised (in AOLserver 4.0
this code moved to bin/init.tcl).

Than I could use procs from mentioned packages in ADPs:

base64::encode xyz

set ch [pop3::open $host $user $passwd]
ns_puts [pop3::status $ch]
set msg [pop3::retrieve $ch 1]
pop3::close $ch

3. TCL packages in AOLserver

Does someone have any experience of how standard TCL packages/extention
perform under real load? Are they thread safe? What is your general impressions?

I certainly would like to use Tcllib. I also consider
using some TCL C extensions like Trf, TrfCrypt, Tcl MIME, TLS.

Trf, TrfCrypt, TLS see http://www.oche.de/~akupries/soft/trf/index.html
TLS see http://www.sensus.org/tcl/

If they are thread-safe they allow to fetch gzipped HTTP
pages or fetch pages using SSL.

Using TCL extention seems to me as the right way to have desired
functionality available in AOLserver. But maybe there are obstacles that I
don't see.

I also wonder why there are ns_* commands that accomplish the same
that standard TCL commands (ex. [ns_unlink] and [file
delete]. Browsing AOLserver sources revealed that some TCL procs are
not thread-safe. Isn't better to make them thread-safe so both AOLserver
and TCL community benefit from that.

Can someone comment these.

--tkosiak

Reply via email to