[Zope] Making a folder-like object?

Yves Bastide Yves.Bastide@irisa.fr
Fri, 01 Mar 2002 14:58:37 +0100


Jerome Alet wrote:
> On Fri, 1 Mar 2002, Yves Bastide wrote:
>=20
>=20
>><a href=3D"http://my.host/retrieve?id=3D42">results.xls</a>
>>where ``retrieve=B4=B4 is the script.
>>
>>I would like instead to be able to present an address like:
>><a href=3D"http://my.host/retrieve/42/results.xls">results.xls</a>
>>
>>This is the only way I know of to pass the filename to the client=20
>>(though I'd be happy to be corrected).
>>
>=20
> Make retrieve set the correct content-type and content-disposition in t=
he
> response's headers, and you'll be able to choose the name of the file.
>=20
> an example with application/pdf as the content-type :
>=20
> <UNTESTED>
> 	...
> 	filename =3D "myfile.pdf"
> 	REQUEST.RESPONSE.setHeader('Content-Type', 'application/pdf')
> 	REQUEST.RESPONSE.setHeader('Content-Disposition', 'attachment; filenam=
e=3D%s' % filename)
>         return filedata()
>         ...
> <UNTESTED>
>=20
> filedata() shoudl retunr the actual file contents.
>=20
 > hth.

Yes, this works enough (wget doesn't grok it, but Mozilla and IE use the=20
filename in their Save As dialog).  Will do!

Thanks J=E9r=F4me,


Yves


>=20
> Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome
> Fac de Medecine de Nice        http://wwwmed.unice.fr=20
> Tel: (+33) 4 93 37 76 30     Fax: (+33) 4 93 53 15 15
> 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
>=20
>=20
>=20