"Bruce Pearson &/or Gwyn Ingham" <BruceP@wn.com.au> wrote:
I want to download generated data to a file on the users computer when they press a button.
The button will call a python script which will generate the data. I'm not sure how to get the browser to bring up a download dialog and not just display the data.
I am trying this.
data = 'This is the data that is generated.'
context.REQUEST.RESPONSE.setHeader('Content-Type', 'application/data') context.REQUEST.RESPONSE.setHeader('Content-Length', len(printed))
^^^^^^^^^^^^ Typo? I think that should be 'len(data)'
context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=Data.dat')
^^^^^^ Doesn't an 'inline' disposition tell the browser that you want it to try to display the data, rather than save to disk?
return data
This display the data in the browser, but doesn't download it.
Hope this helps, Tres. -- =============================================================== Tres Seaver tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
On Tue, 29 May 2001, Tres Seaver wrote:
context.REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=Data.dat') ^^^^^^ Doesn't an 'inline' disposition tell the browser that you want it to try to display the data, rather than save to disk?
No, it tells "data is right here, after the headers". Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
participants (2)
-
Oleg Broytmann -
Tres Seaver