[Pythonmac-SIG] Doc cgi python

Jack Jansen jack@oratrix.nl
Sat, 25 Mar 2000 00:02:23 +0100


Something that would be nice to have, and doable for simple cases (see 
below) is a wrapper that is implemented with MiniAEFrame but exports
an interface similar to what Unix and Windows CGI scripts get.

The WebStar/MacOS way of doing things is superior from a design point
of view, with the cgi-request coming in as an AppleEvent and the
result going back as the reply to that AppleEvent, but with 90% of the 
CGI scripts being written for Unix I guess we'll have to adapt.

The good news is that in Python we can do so with relatively little
pain. With StringIO objects for sys.stdin and sys.stdout and a
sys.environ setup to match what Unix CGI scripts get we're all set to
execute Python CGI scripts that expect the unix way of things. A nice
added advantage, if things are setup right, is that the long-running
server advantage Just sketches is automatically available, where under 
Unix this requires a completely different structure of your CGI
scripts.

This will however only be really easy for the simple case: AppleEvent
replies can be at most 32Kb. WebStar has special measures for handling 
larger replies, whereby AppleEvents go the other way. I think,
however, that this is difficult to implement in Python with the
current AppleEvent implementation, because it breaks the pure RPC
model through which MiniAEFrame works. It may be doable with a bit
more work and/or with multiple threads, though.

All that said, I'm not going to do the implementation work because I
don't have the time and no real application for it. But, as always,
I'm more than willing to give advise, and I'll graceously accept
donated code:-)
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm