[Seaside] How to set the mime-type of a response?

Julian Fitzell julian at beta4.com
Wed Oct 15 11:00:51 CEST 2003


Hi Ian,

What you probably want to do is create the link to the document by 
calling #anchorWithDocument:mimeType:text: or #anchorWithDocument:text: 
on WAHtmlRenderer.  You could, for example, have a render method like:

renderContentOn: html
html
	anchorWithDocument: self myFileContents
	mimeType: 'application/pdf'
	text: 'Download my PDF'

It looks like whatever object you pass in as the document needs to 
implement asMIMEDocument, which at the moment seems to limit it to 
Strings, Forms, and Images.  I imagine it could be implemented for other 
things like Streams, but it would just have its contents pulled out at 
that point anyway.  The additional benefit of this method is that the 
document is cached so if it is downloaded again the browser will be able 
to use its cached version.  This is based on content so as soon as the 
document is changed it will have a different ID and will get downloaded 
again.

Julian

Ian Prince wrote:
> Hello All,
> 
> I have been following Seaside since 0.91 and it reminds me of Bobo back 
> in 1998 before it became Zope - wonderfully simple and elegant.
> 
> Anyway here's my first question: I am trying to return the contents of a 
> file read from disk (or created on the fly) but can't find out how to 
> set its mime-type.
> 
> In Zope/DTML I think this would be as follows for a PDF document:
> 
>     <dtml-call "RESPONSE.setHeader('Content-Type', 'application/pdf')">
> 
> How can I do this in Seaside (I'm using Seaside2.3b5.st)?
> 
> My apologies if I'm missing something very obvious.
> 
> Thanks in advance,
> 
> Ian.
> 
> -- 
> ian prince - inextenso - 1 ruelle des moulins - 1260 nyon - switzerland
> ian at inextenso.com - tel +41 22 990 10 80 - mobile +41 78 880 27 02
> 
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside




More information about the Seaside mailing list