I'm having troubles using zope. I just need to serve to the client a xls file created with python xlwt module but I don't find the way to do that.
In my .pt file I have a button that calls a .py function, this function creates correctly the file, but it doesn't serve it to the client browser. I'm trying in this way:
f = open(temp_file, 'rb').read()
self.request.response.setHeader('Content-Type', 'application/vnd.ms-excel')
self.request.response.setHeader('Content-Disposition',' attachment; filename=Excel_Workbook.xls')
return f
How can I do that?
Thanks everybody!
How are you calling the script? You need to invoke it directly from a URL, not from your template.
Include a download URL in your template that points to your python script: