[ZPT] python: path(request/foo) or 0
Martijn Pieters
mj@zope.com
Mon, 4 Feb 2002 11:39:50 -0500
On Sun, Feb 03, 2002 at 11:02:13AM -0500, Evan Simpson wrote:
> For a while, "path('whatever')" in a Python expression would evaluate to
> an un-raised exception if the path failed to resolve. This exception
> was false-valued, so the OR trick worked. This was a Wrong Thing, and
> caused other problems. The proper way to do this now is:
>
> python:path('whatever | nothing') or 0
For request variables, what also works is:
python: request.get('varname', default)
--
Martijn Pieters
| Software Engineer mailto:mj@zope.com
| Zope Corporation http://www.zope.com/
| Creators of Zope http://www.zope.org/
---------------------------------------------