[Zpt] TALES

Guido van Rossum guido@digicool.com
Fri, 02 Mar 2001 11:21:19 -0500


> I added comments to Todd's comments on TALES.  I have a few issues for
> discussion.
> 
> First, I suggest adding a way to handle existence testing:
> 
> Add expression type "exists", which takes a path expression and returns a
> boolean value indicating whether the path successfully resolves::
> 
>     <span z:condition="exists:template/annotation"
> z:replace="template/annotation">

Seems like a good idea to me.

> Alternatively, make path expressions that fail to resolve evaluate to
> singleton value "Undefined" instead of raising an exception.  "Undefined"
> would be false, so we could write::
> 
>     <span z:define="ann template/annotation" z:condition="ann"
> z:replace="ann">

Not so cool.  If this is voted in, maybe in z:condition, Undefined
could evaluate as false?

> Next, how should path resolution in Python expressions look?  I think that
> we have agreed to make all template variables available to Python
> expressions directly, so that we can simply write expression like "python: x
> + y".  What about paths, though?  The alternatives seem to be::
> 
>    <span z:define="x here/to/there" z:condition="python: x == 1">
>    or
>    <span z:condition="python: here.restrictedTraverse('to/there') == 1">
> 
> Is this acceptable?

It would be better if instead of restrictedTraverse() we could come up
with a shorter method name, e.g. get().

--Guido van Rossum (home page: http://www.python.org/~guido/)