On 12/22/2012 02:10 AM, Jason wrote:
hi Jason,
Thanks for the idea.
Once you have the ods as a file object in your view-callable you can
return it with something like:
filecontent = myfile.read()
headers = {
'Content-Type': 'application/ods',
'Content-Length': len(filecontent),
'Content-Disposition': 'attachment; filename=myfilename.ods' }
return Response(filecontent, headerlist=headers.items())
I tried this.
curdir = os.getcwd()
ledgerfile = open(curdir + "/Ledger.ods","r")
ledgerdata = ledgerfile.read()
headers =
{'Content-Type':'application/vnd.oasis.opendocument.spreadsheet'
,'Content-disposition': 'attachment; filename=' + curdir +
'/Ledger.ods', 'Content-Length': len(ledgerdata)}
ledgerfile.close()
return Response(ledgerdata, headerlist= headers.items())
Note that this is the Response object resulting from
from pylons.controllers.util import abort, redirect, Response
So it is not the response (with a small r ) as in from pylons import
request response, although this import is also there in my code.
Now what happens is that my browser (Firefox) displays the content of
spreadsheet in a junk form instead of showing me the dialog box to
download the file.
Can any one suggest what could be the problem?
Happy hacking.
Krishnakant.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.