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

Godefroid Chapelle gotcha@swing.be
Thu, 26 Apr 2001 10:05:46 +0200


zpt-request@zope.org a =E9crit :

> From: "Evan Simpson" <evan@digicool.com>
> To: <zpt@python.org>
> Date: Tue, 24 Apr 2001 12:33:41 -0400
> Subject: [ZPT] Possible changes to path-related
>
> 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 operat=
e
> 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 realize=
d
> that it doesn't need to be implemented that way.  We can replace these
> multiple expression types with simple path expression prefixes, as desc=
ribed
> 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 cance=
l 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 tomorr=
ow,
> hopefully with these features.
>
> Cheers,
>
> Evan @ digicool
>

Though I am lacking experience with building Zope sites, the design objec=
tive
seems OK.

I am just afraid of multiplying the number of special syntax cases. We sh=
ould
avoid to approach the TMTOWTDI by not being careful enough.

What I mean is that it is easy to understand why the 'exists' construct i=
s
unique to path.

It is may not be so obvious for the 'if' construct. Are there reasons to =
not
extend it to other expression types ? I imagine cases where a Python expr=
ession
returns None or '' and where it would be useful to have the 'if' construc=
t. And
even if the following expression seems stupid (if string:) I see no reaso=
n to
forbid it.

I have read the TALES specification again and have the feeling that, unde=
r
prefixes, orthogonal concepts are classified as same things.
I think that the distinction between prefixes responsabilities should be =
made
more clear.
It would also allow to have a more clear syntax description.

I propose the following as a summary of the different documents : express=
ion
types, path modifiers, expression result modifier, action modifier

For example,

three expression types : string, path, python

two path modifiers : nocall, exists as described in
http://dev.zope.org/Wikis/DevSite/Projects/ZPT/PathExpressionVariants

one result modifier : not

action modifier : if

Finishing this description, I feel uneasy about the role of the 'if'. As
described above it has u fuzzy poistion between TAL and TALES.
If I understand the points, could the 'if' construct be explained as foll=
ows ?

'if' acts as a function changing the boolean value true to 'execute TAL a=
ction'
and the boolean false to 'cancel TAL action'.
Those two 'things' could be seen as special TAL constant values.

But then, what does happen when there are multiple TALES expression in a
multiple TAL 'define' ? I would like to avoid the situation where the if
construct can be used in certain TAL action and not in others...

I hope those thoughts can help... even if they are not so well structured=
 anf if
I am not sure I have followed the thinking process enough to grasp the wh=
ole
story.

--

Godefroid Chapelle

BubbleNet sprl
rue Victor Horta, 30
1348 Louvain-la-Neuve
Belgium

Tel 010 457490
Mob 0477 363942

TVA 467 093 008
RC Niv 49849