[ZPT] Re: ZPT digest, Vol 1 #62 - 1 msg

Evan Simpson evan@digicool.com
Thu, 26 Apr 2001 10:18:08 -0400


From: "Godefroid Chapelle" <gotcha@swing.be>
> I am just afraid of multiplying the number of special syntax cases. We
should
> avoid to approach the TMTOWTDI by not being careful enough.

Agreed.  Also, Jim pointed out to me that we're in danger (when omitting the
optional 'path:') of having lists of words, separated only by spaces, with
very different roles.  For example, tal:define="global x if exists y".  I
propose enclosing path modifiers in parenthesis, producing:

tal:define="global x (if exists) y", tal:replace="structure (nocall)
here/this"

> It is may not be so obvious for the 'if' construct. Are there reasons to
not
> extend it to other expression types?

While 'if' isn't really path-specific, it has synergy with 'exists'.
Ordinarily, 'exists' checks to see whether a path resolves.  It doesn't
examine the value of the path, or try to call it, so 'exists' returns true
(1) even if the path evaluates to a false value like 0 or ''.  The combined
'if exists' modifier resolves the path normally, and doesn't convert the
resulting value in any way.  Its only effect is to retrun CancelAction if
the path doesn't exist.

The 'CancelAction' value can be made available to Python expressions, so
that they can return it to cancel actions.

> three expression types : string, path, python
> two path modifiers : nocall, exists
> one result modifier : not
> action modifier : if

The path modifiers are really implementation details of the path expression
type, and 'not' is a proper expression type (syntactically).  I agree that
it's helpful to have the further behaviour classification, though.

> 'if' acts as a function changing the boolean value true to 'execute TAL
action'
> and the boolean false to 'cancel TAL action'.

Not exactly.  'if' passes a true value (in the Python sense) unchanged.  It
does change boolean false into CancelAction.

> But then, what does happen when there are multiple TALES expression in a
> multiple TAL 'define'?

It affects exactly the part of the action in which it is used.  If 'X'
exists and 'Y' does not, then the following statement will set 'xvar' to 'X'
but will not define 'yvar':

tal:define="xvar (if exists) X; yvar (if exists) Y"

Similarly, tal:attributes replaces or doesn't replace each attribute
independently.

Cheers,

Evan @ digicool