[Zope] Making a folder-like object?

Jerome Alet alet@unice.fr
Fri, 1 Mar 2002 14:44:13 +0100 (MET)


On Fri, 1 Mar 2002, Yves Bastide wrote:

> <a href=3D"http://my.host/retrieve?id=3D42">results.xls</a>
> where ``retrieve=B4=B4 is the script.
>=20
> 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>
>=20
> This is the only way I know of to pass the filename to the client=20
> (though I'd be happy to be corrected).

Make retrieve set the correct content-type and content-disposition in the
response's headers, and you'll be able to choose the name of the file.

an example with application/pdf as the content-type :

<UNTESTED>
=09...
=09filename =3D "myfile.pdf"
=09REQUEST.RESPONSE.setHeader('Content-Type', 'application/pdf')
=09REQUEST.RESPONSE.setHeader('Content-Disposition', 'attachment; filename=
=3D%s' % filename)
        return filedata()
        ...
<UNTESTED>

filedata() shoudl retunr the actual file contents.

hth.

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