Nsapy - 0.4b

Gregory Trubetskoy, May 16 1998

NEW: The port to Apache is here: Httpdapy 0.1b.

NEW: A precompiled version of the Windows DLL for Python 1.5 is available here (Netscape 3.0 server).

What is it?

Nsapy is an extension to the Netscape http server that embeds Python within the server using NSAPI. Simply speaking, Nsapy allows you to write real NSAPI applications using Python.

Who is responsible for it?

Original implementation was conceived by Aaron Watters and published in the book "Internet Programming with Python". I modified this code quite a bit and added several features to it. What you will find here is quite different from what's in the book, though the underlying mechanism is the same.

I also added a Copyright. This was done mainly to clarify that Nsapy is indeed free, and to make sure that the name isn't used anywhere else. See COPYRIGHT for details.

What's so good about it?

For one, you don't have to be an expert C programmer to create NSAPI applications. In fact, using Nsapy may be easier than CGI, once you figure it out. I also think it's easier and more flexible than LiveWire at this point.

Second advantage is speed. Your Python script will run within the server itself, not as a separate process. In this respect, Nsapy has the same advantage as FastCGI, ISAPI, etc.

Yet another advantage is the ability to perform initialization at server startup. Because Nsapy programs run within the server's memory space, all the variables persist for as long as the server is running. This was the main reason why I decided to get into this in the first place. I had a CGI application that loaded a bunch of lookup files with every hit. This was taking too much time, so I decided to use NSAPI. Now, I load the lookup files at server startup time and keep them in dictionaries. Needless to say, this was a tremendous performance boost.

There are other things that Nsapy can do. You can, for example, provide a custom authentication mechanism using a Python script. With a wealth of database modules available for Python, it is very easy to store user logins and passwords in your own custom database.

What's new in this version?

Support for extensive logging, including thread id's.

Support for critical sections. Although Python has its own thread locking support, I found it flaky when used in Nsapy. Netscape's crit_* functions, however are rock-sold. There is now a Python interface to crit_init(), crit_enter() and crit_exit().

How much is it?

Nsapy is available free of charge, see the COPYRIGHT file though.

Where can I get it?

The current version is not yet of production quality, but seems to be very stable. Because compiling this involves having Python sources and may be more trouble than you may want to get into right now, I have compiled binaries for windows NT (Intel) and  Solaris (SPARC). These are the only OS's that I have Netscape servers for, feel free to port it to anything else and please let me know if you succeed. To download the latest version click here http://www.ispol.com/home/grisha/nsapy/nsapy-0.4b.zip (NT) or here http://www.ispol.com/home/grisha/nsapy/nsapy-0.4b.tar.gz  (Solaris). If you want source only, look here http://www.ispol.com/home/grisha/nsapy/.

Where is the documentation?

At this point I only have a small readme. There is also documentation in the source files nsapimod.c and nsapy.py.


Gregory ( Grisha ) Trubetskoy