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

Tino Wildenhain tino at wildenhain.de
Mon Apr 30 11:06:58 EDT 2007


Charu ASTHANA schrieb:
> 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.
> 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)

Well what you edit via browser in Zope is called thru-the-web scripting
and is made as secure as possible. So you _dont_ have access to the
servers filesystem from there.

However, you have extfile and localfs as ready to install products
which enable limited filesystem access to create the objects there.

Still then you would have to find a way to call that external
script.

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

External methods are created as python source files in the extensions
directory and contain at least one function. In these scripts you
can do everything python enables you to do, including filesystem access
and popen() for startig external tools.

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

There are a lot cerveats when it comes to such constructs. You can
easily enable big security holes to your system when you arent
very carefully. Thats why TTW-scripting is so isolated.

Btw, what exact type of "some calculations" does your perl
script do? I'd expect it easier to just rewrite it in
pure python.

Other approaches would be to provide the form in zope maybe
and then just direct the action to a cgi-bin which is or
calls your perl script (depending on its interface)

Regards
Tino


More information about the ZPT mailing list