[Zope] newbie CGI question

Michel Pelletier michel@digicool.com
Wed, 22 Mar 2000 10:44:50 -0800


You know after reading this thread I was pretty surprised that we didn't
have simply execcgi ability in Zope, considering how trivial it is.

I'll look into something like this possibly being a feature.

Thanks Tres!

-Michel

Tres Seaver wrote:
> 
> "Eric Walstad" <ewalstad@energywright.com>
> >
> > Hung Jung Lu ,
> > Along these same lines, I have a C++ CGI App that I would like to call from
> > zope.  It requires a couple of parameters.  The app can either return HTML
> > or I can have it save the output to a text file.  Ultimately, the text will
> > need to be displayed to the user from Zope.
> > Q1.  How does one call a C++ CGI program from Zope?
> > Q2.  How do you supply the C++ CGI program with "command line" parameters
> > from Zope when making the call?
> 
> From Python (either an ExternalMethod or a product)::
> 
>   import sys, os, string
> 
>   def ExecCGI( cmdLine ):
>       """
>       Run an external command and return its standard output as a string.
>       """
>       f = os.popen( cmdLine ) # note that Win32 has a non-standard popen()
>       lines = f.readlines()
>       status = f.close()
>       if status:
>          raise "CGI returned error: %d" % status[1]
>       return string.join( lines )
> 
> To call it from DTML, passing the current values of 'foo' and 'bar'::
> 
>    <dtml-let cmdLine="'/path/to/my/cgi %s %s' % ( foo, bar )">
>      <dtml-var "ExecCGI( cmdLine )">
>    </dtml-let>
> 
> Tres.
> --
> =========================================================
> Tres Seaver         tseaver@palladion.com    713-523-6582
> Palladion Software  http://www.palladion.com
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )