[ZPT] Page Template Preconditions?

Evan Simpson evan@4-am.com
Fri, 09 Aug 2002 15:14:36 -0500


Jeffrey P Shell wrote:
> So then I tried doing a <..tal:define="dummy
> python:here.checkSession(...)">, but in any combination I tried the redirect
> never happened - raising one just brought up TALESError, and I think a
> 'RESPONSE.redirect(...)' call just got swallowed.

These should both work :-(

> So what I'm wondering is if there's been any thoughts to doing some sort of
> 'precondition' script/expression, or adding in some event hooks to Page
> Templates?  ASP.NET (and possibly earlier versions) has a Page_Load(...)
> event handler that developers can write.

I have developed a pattern for pages that require a lot of prep work 
(especially form/wizard participants) that involves directing all 
requests to a Script.  The Script does the prep, then usually ends with 
a 'return container['scriptname.pt'](somedata=somedata)'.

It would certainly be possible to add a 'pre-publish' field to ZPT, with 
the value interpreted as a TALES expression.  I would expect this to be 
evaluated only when the ZPT is being published directly, not when it's 
called from other code.  The only questions remaining in my mind would 
be how to best make the ZPT object available to the Script (if the 
expression calls a Script) and how to interpret the value of the 
expression.  If the expression evaluates to a tuple, list, or mapping, 
it would be straightforward to place in 'options'.  It might be helpful 
to interpret a string as "publish this instead of the template".  What 
about other values?

Cheers,

Evan @ 4-am