[Zope] RESPONSE.setHeader

Tino Wildenhain tino@wildenhain.de
Tue, 29 May 2001 13:59:24 +0200


Hi Paul,

you have to set the header on the resource you want to
download, not on the page containing the links.
You can make a simple download method like this:

<dtml-call "RESPONSE.setHeader('content-type','application/octet-stream')>
<dtml-call "RESPONSE.setHeader('Content-Disposition','Attachment; 
Filename=' + id() +'.txt')">
<dtml-return "_[id()]">

as a method "download", so you can use

yourdocument/download  do download yourdocument.txt

HTH.
Tino Wildenhain

PS: note: untested. May be you have to vary some things in the source, 
(like id() )
but it schould be good for a starting point.



--On Dienstag, 29. Mai 2001 13:17 +0200 Paul Zwarts <paz@oratrix.com> wrote:

> Hi,
>
> Does anyone know how to setHeader of the RESPONSE to a document in Zope
> which would ordinarily be read as an html file will now be downloaded?
>
> I list some files in a page and then I want to be able to download these
> documents, but of course the browser will load and render them.
>
> I have tried:
>    <dtml-call "RESPONSE.setHeader('Content-Disposition','Attachment;
> Filename=' + document)">
>
> where document is the &dtml-absolute_url; of the object I want. But it
> will give me a popup window to save the HTML file of the page that lists
> the files I want available for download.
>
>    <dtml-call "RESPONSE.setHeader('refresh', '4;URL=' + document)">
>
> Will of course get me the correct page as well, but again, the browser
> will render it since it is in fact of DTML Document type... But how do
> you force a download?
>
> Thanks again,
> Paz
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )