[Zope] ZServer serving CGI by itself

Fred Wilson Horch fhorch@ecoaccess.org
Sun, 05 Nov 2000 18:42:22 -0500


Eric,

Thank you very much for the example code.  That basically does what I
want.

However, I have a couple of added complexities.

First, I have a lot of scripts, not just one.  I'd like to have the
equivalent of a ScriptAlias in Apache, where I can tell Zope to treat
everything in a certain directory as a CGI script.

Second, my scripts do funky things like set cookies for authentication. 
So I need to tell Zope to basically get out of the way after calling the
CGI script.  (Specifically, I don't want Zope sending the HTTP header.)

Third, some of my scripts are long running processes and I'd like to be
able to send results back to the client unbuffered.  With Apache 1.3.x,
I'm able to run Python scripts with the -u flag to the Python
interpreter to force unbuffered output (i.e. you see the progress
instead of having to wait for the script to finish).

I'm thinking of writing a CGIScript product to handle this.  My idea is
that I could add a CGIScript object to any Zope folder, setting
parameters as appropriate.  Parameters could include:

1) name of CGI script to execute on host machine or name of directory
containing CGI scripts
2) buffer output
3) script sends HTTP headers
4) environment variables
5) exception handling

Has a general CGI product in Zope already been done?  I've already
written a few external methods in testing Zope, which is easy enough,
but haven't yet tried to write a product.  How hard is it?  Anyone have
any advice (aside from go with the flow and run Zope behind Apache)?

Thanks,
Fred

P.S.  Is standard_error_message broken in Zope 2.2.2?  I couldn't figure
out how to use error_value without the code in
lib/python/ZPublisher/HTTPResponse.py throwing in extra <html> tags.  I
finally just edited that file and things seem to be working.  Running
with or without the -D flag didn't make any difference.

Eric Walstad wrote:
> 
> I have a C++ program I run from Zope and then return the results to Zope.
> Just like you described, I farm the work out to an external method which
> runs the CGI, grabs the results and hands them back to Zope.  Be sure to
> hard code the line that calls your CGI.  Otherwise, the External Method
> could be used to call any (potentially damaging) code on your Linux box.
[snip]