[ZPT] Page Template Preconditions?
Jim Fulton
jim@zope.com
Sat, 10 Aug 2002 08:25:28 -0400
Evan Simpson wrote:
> 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 :-(
I wonder why they didn't. This doesn't seem like it should be
hard to do.
>> 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)'.
I have a similar pattern, except, I usually have a single define
at the top of the template that calls a Python method that computes
a data structure containing the things I need.
> 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?
This all sounds too complicated to me. Surely, we don't need this.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org