[ZPT] TALES
Jim Fulton
jim@zope.com
Wed, 12 Feb 2003 13:57:21 -0500
Evan Simpson wrote:
> Florent Guillaume wrote:
>
>> How would you do the following in TALES?
>>
>> python:here.foo(1,2,3) | python:here.bar(4,5)
>
>
> Ooh, tricky. I can only think of two ways, and one is undocumented.
> First, if you could factor "here.foo(1,2,3)" into a Script, you could use:
>
> here/foo123 | python:here.bar(4,5)
I'm surprised you can have a tales expression after the "|".
> If you're willing to use an undocumented expression type that could go
> away in the future, try:
>
> tal:define="foo123 defer:python:here.foo(1,2,3);
> result foo123 | python:here.bar(4,5)"
I think that this is a bad idea, especially since you didn't
even say what "defer" does, which, I guess, is in keeping with
it's undocumentedness. :)
I also didn't think that "|" caught *all* exceptions. Does it?
I think the right answer to this question is to write a Python script
that does:
try:
return here.foo(1,2,3)
except something:
return here.bar(4,5)
and call the script from tal.
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