[ZPT] response.setHeader() best practice

seb bacon seb@jamkit.com
03 Apr 2002 16:03:33 +0100


On Wed, 2002-04-03 at 15:03, Harry Wilkinson wrote:
> On Wednesday 03 April 2002 2:34 pm, Florent Guillaume wrote:
> > seb bacon  <seb@jamkit.com> wrote:
> > > Could anyone point me to a nicer way of doing:
> > >   <span tal:content="nocall:python:response.setHeader('blah')"></span>
> > > ...using 'content' feels like an abuse of the attribute in this context.
> >
> > Not that nicer, but I use:
> >
> > <tal:block define="dummy python:response.setHeader('blah')" />
> >
> >
> > Florent
> 
> 
> This seems out of place in a page template to me.  My impression of the 
> 'correct' way to use page templates was only to present data acquired from 
> lower layers, and leave the function calls that are used as procedures (ie 
> not using the return value as part of the presentation of the page) to Python 
> scripts.
> 
> Perhaps that's incorrect, or just unnecessarily purist.  Still, it doesn't 
> seem to me like the kind of thing that ought to be in a page template.
> 
> What do you think?

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