[ZPT] How to write input to a file and run a perl script

Charlie Clark charlie at egenix.com
Mon Apr 30 11:18:33 EDT 2007

Am 30.04.2007, 15:23 Uhr, schrieb Charu ASTHANA <asthana at loria.fr>:

> Dear users,
>  I am fairly new to zope.  i am not much of a computer scientist but I  
> can do some programming.
> ok so here is my problem:

>  I have ot create a web page, which asks the user for some inputs and  
> upload of a data file.

> The input values and the file name (the uploaded file will be saved on  
> the server) are to be written to a text file that will be saved on the  
> server.

Why do you want to save to a file rather than the Zope database? If you  
need access to the file system you must use an ExternalMethod.

> This text file will then be given as input to a perl program that will  
> read and do some calculations.
>  Now I have reached so far:

> I have created a web page which asks for user inputs.

> Then when the user submits the form :
>   a) I create another web page that shows the user what all he has  
> inputted and ,
>    b) also send the input ( thought he set parameter list) to a python  
> script.

>  Now I am not able to understand ???

> 1) how to write all the set of parameter that python script has got onto  
> a text file ( i do not clearly understand about the limitations of  
> script in zope context)

Look at context.REQUEST.form in the PythonScript for the values. You  
cannot access the file system from within a PythonScript

> 2) Also how do I call a perl script from this python script. ( i could  
> not understand the concept of external methods)

You cannot. How complex is the perl script? It might make sense to rewrite  
it in Python to be able to use it from within Zope otherwise you must use  
an ExternalMethod to invoke your perl script, pass it the data and get a  
response from it but would be fairly complicated.

>  Any pointers will be very helpful. Also any example of similar code  
> will be beneficial.

For what you want to do it seems strange to want to use Zope rather than  
using a Perl cgi script. If you are going to stick with the Zope then you  
should probably spend some time reading the Zope Book to understand what  
Zope is, how it works and what it lets you do.

Charlie Clark

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

     eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the ZPT mailing list