[Pythonmac-SIG] CGI on Mac/WebStar using Python

Noboru Yamamoto noboru.yamamoto@kek.jp
Thu, 09 Dec 1999 10:14:53 +0900


Hi,

Two days ago, I decided to write a CGI program for WebStar(a commercial
WWW server for Macintosh).
I found a sample CGI program for Mac/WebStar in Mac/demo/cgi folder of
Mac/Python distribution.
I took it, realcgitest.py, and converted it to an Python applet using BuildApplet.
Then I put it in the folder where the WebStar can access. It works OK
and I extend the cgi program
little by little and tested it. In this process, I noticed one glitch.
First attempt to the cgi program always fails if the cgi program is not
running. 
If you start the cgi by hand or second attempt to the cgi from WWW
browser works just fine.
After a long test and consideration, I concluded that an event loop to
support python console window
takes a first Apple event and it does not pass it to a callback function
for the WebStar/CGI event('WWW\275', 'sdoc')
because the callback is NOT installed yet at this point.

This morning, I turned ON three startup options for Python on the mac
running WebStar.
Three options I turned on are:
	1) Disable Interactive option setting
	2) Disable argc/argv emulation
	3) Delay console window until needed.
With this setting, the phenomena I mentioned disappear. All CGI request
from WWW browser are handled 
properly even if the CGI program is not running. So you can use set
self.quitting = 1 at the end of CGI callback
to terminate execution of the CGI program.

I didn't check if it is really necessary to turn on all three options.
It may be enough to turn on the third option("Delay console window until
needed") .

Regards,

Noboru Yamamoto
Accelerator Lab.
KEK, High Energy Accelerator Research Organization
Tsukuba, Ibaraki
JAPAN