[Zope] RESPONSE.setHeader

Paul Zwarts paz@oratrix.com
Tue, 29 May 2001 14:31:49 +0200


Hi Tino,

Thanks for the response. I *think* I understand what you mean. Here is the
layout

SMILTests <- the viewing document that scans the following folders for
documents and then lays them out as various types and recognizes the
differences by their extension

SMILTests - viewing file
getDoc    - your suggested method
  Interop (folder)
      Animation (folder
           something.smil     - a .smil file to be downloaded
           something.smil.html - the corresponding source file to read
      Media (more folders)
      ...
      ...


The SMILTests document will compile a list per folder. From this same
document, I want to cause the download of the requested file, which btw, are
ALL DTML Documents.

<a href="getDoc?document=something.smil&area=Animation">this file</a>


So it goes to getDoc which has:

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

Which gets itself to the correct folder in a folder, and the file... And the
<dtml-return> should var the ultimate destination into the current method,
or......?

Thanks,
Paz


So what you are saying is in the SMILTests document, the a href should look
like
-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Tino
Wildenhain
Sent: 29 May 2001 13:59
To: Paul Zwarts; Zope
Subject: Re: [Zope] RESPONSE.setHeader


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.