[ZPT] Possible changes to path-related

Guido van Rossum guido@digicool.com
Wed, 25 Apr 2001 14:09:50 -0500


> I'm almost ready to release ZPT 1.2, and I'm trying to nail down the
> implementation of:
> http://dev.zope.org/Wikis/DevSite/Projects/ZPT/ActOnlyIfPathExists
> 
> In the process, I decided that overloading 'exists' was not the best
> solution.  Instead, I suggest adding an 'if' modifier that could operate
> alone or in combination with 'exists'.  It would cancel the TAL action using
> a path expression if the value is false.  When combined with 'exists', it
> would do so if the path is undefined, but return the rendered value if the
> path is defined.
> 
> Combining path expression types like this would be messy, and I realized
> that it doesn't need to be implemented that way.  We can replace these
> multiple expression types with simple path expression prefixes, as described
> at:
> http://dev.zope.org/Wikis/DevSite/Projects/ZPT/PathExpressionVariants
> 
> With these two proposals, we could modify an expression such as
> 'request/foo' four ways (plus any of these with nocall added):
> 
> 1. request/foo
>     Return the value of 'request/foo' if it is defined, otherwise raise an
> exception.
> 2. if request/foo
>     Return the value of 'request/foo' if it is true, raise an exception if
> it is undefined, otherwise cancel the action.
> 3. if exists request/foo
>     Return the value of 'request/foo' if it is defined, otherwise cancel the
> action.
> 4. exists request/foo
>     Return true (1) if the value of 'request/foo' is defined, otherwise
> return false (0).
> 
> Please comment immediately, if you can.  I'd like to release 1.2 tomorrow,
> hopefully with these features.

Evan, it would seem that you need changes to the TAL interpreter to
implement cancellation of actions, right?  Have you done this yet?  Do
you need me to look into it?  Or is it too late (given that you wrote
"tomorrow" yesterday :-)?

I'm a bit uncomfortable with the three-way possible outcomes (do it,
exception, or cancel), and with the scope of cancellation if
multiple actions are placed on the same element.

I'm not at all sure I like the use of "if" in this syntax -- the
placement of "if" in the guts of the expression to control the whole
statement makes me think of Perl. :-)  But I don't have an
alternative... :-(

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