[Zope] python Script and download file
Hervé Richard
Herve.Richard at avignon.inra.fr
Fri Dec 5 09:53:48 EST 2003
Tanks for your answer,
It almost works but ... here is my script (named "sendMeAr") :
----------------
# 3 differents formats compressed files :
archiveMac ='arMacV2.sea.hqx' #these files are in my current folder
archiveWin ='arWinV2.zip'
archiveUnix='arUnixV2.tar.gz'
fileObj=''
#I get the response from the form :
OS = request.form
systeme = OS['submit']
if systeme == 'Unix':
container.Ar_Unix.increment(1)
fileObj = getattr(context, archiveUnix)
elif systeme == ' Mac':
container.Ar_Mac.increment(1)
fileObj = getattr(context, archiveMac)
elif systeme == ' Win':
container.Ar_Win.increment(1)
fileObj = getattr(context, archiveWin)
return fileObj.index_html(context.REQUEST, context.REQUEST.RESPONSE)
-------------------------
When i try, if i hit Unix button i get the popup to download
arUnixV2.tar.gz, and so on,
BUT
the name of each of file is :
for mac button : sendMeAr29ac392e in place of arMacV2.sea.hqx
for unix button : sendMeAr39d43f39 in place of arWinV2.zip
for win button : sendMeAr3a318f43 in place of arUnixV2.tar.gz
How can i pass the good attr name to the return file ?
Tanks again
Dieter Maurer wrote:
> Hervé Richard wrote at 2003-12-4 15:30 +0100:
>
>>It's probably a newbie question :
>>I want to write a python script form action which return a file to
>>download:
>>In a folder i have 2 files ("A.tgz" and "B.tgz") and a Page Template
>>Object (download.html). This page is a form with multiple choice in
>>order to seclect a file to download (if the user select "A" button, he
>>get the A.tgz file, if select "B" he get A.tgz ...) I want to write a
>>python script method to render the file but i don't know how create the
>>command to pass the file to downlown.
>
>
> I do not understand what you mean with "create the command to pass the file".
>
> If the file is a Zope "File" object, then its "index_html"
> renders its content. Your PythonScript could return in this
> case:
>
> return fileObject.index_html(container.REQUEST,
> container.REQUEST.RESPONSE
> )
>
--
_____________________________________________________________________________
Herve RICHARD Herve.Richard at avignon.inra.fr
INRA - Biometrie
_____________________________________________________________________________
More information about the Zope
mailing list