[ZPT] response.setHeader() best practice

Harry Wilkinson harryw@nipltd.com
Thu, 4 Apr 2002 11:06:25 +0100


On Wednesday 03 April 2002 4:03 pm, seb bacon wrote:
> I agree.
>
> Are you saying that setting a header should only be set in a Product, or
> in a python script?  People who develop TTW only have the option of
> using ZPT + python scripts, and in this case there is still a problem:
>
>   <tal:block define="dummy here/setBlahHeader" />
>
> There is a semantic mismatch between the intent of the attribute
> 'define' and the role of the expression.
>
> In this case, I want a <tal:block execute="here/setBlahHeader" /> or
> similar.  Or can you think of a better solution?
>
> seb

The most obvious solution (to me) seems to be to use a Python script in the 
place of this ZPT, and do any setHeader type stuff in that script, then 
return your original page template, which now lives under a different name.

I don't have any context-specific info to think about, though.  Perhaps this 
is a more purist approach to the problem, but not so pragmatic.  It's not 
worth it if it causes more hassle than it saves.

Setting headers does seem a like a presentation-specific action, so it's the 
kind of thing we want in the presentation layer.  Hmm.

If it was just me writing it, I'd probably think about it a bit and decide to 
do exactly what you've done so far, since that seems like where it ought to 
be, even if the syntax isn't pretty.

I wonder if there's anything else presentation-specific, like setting 
headers, that would call for your tal:execute, or basically a dtml-call 
equivalent.  


Harry