[Zope] catching exceptions in zpt

Andreas Jung lists at zopyx.com
Tue Mar 11 01:19:22 EDT 2008

--On 10. März 2008 13:55:27 -0700 David Bear <david.bear at asu.edu> wrote:

> I'm trying to do something like this in a zpt
> <meta tal:define="global target python:here.mysript(request.target) |
> nothing" />

Please don't invent new syntax (you're mixing Python and TALES 
expressions). First 'global' variable definitions
are usually not needed and considered bad. Use nested scopes instead (as we
all do). Second, a tal:condition="request/target | nothing" allows you to
to call the block only if target is present within the request. Third you 
might use getattr(request, 'target', 'default_target') in order to call 
myscript() with a reasonable default value as needed or use something like 

< meta tal:define="t request/target | string:default_target;
                   target python: context.myscript(t);
                   " />

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20080311/acece8e7/attachment.bin

More information about the Zope mailing list