[ZPT] Possible changes to path-related
richard@bizarsoftware.com.au
richard@bizarsoftware.com.au
Thu, 03 May 2001 11:45:24 +1000
Evan Simpson wrote:
> From: "R. David Murray " <bitz@bitdance.com>
> > (use-if-exists-and-true) ?
>
> Eeek!
Indeed! :)
> > > tal:action="path:(if exists) foo"
> > > if exists('foo'):
> > > action(foo)
> >
> > Shouldn't this read:
> >
> > if exists('foo') and foo:
> > action(foo)
>
> Well, I don't know about "shouldn't". It corresponds accurately to the
> current implementation. Whether the implementation ought to behave this
> way is another question.
Er, this isn't the behaviour for me... I get #4 below... And I want it to
stay that way! :)
> I'm trying to cover four use-cases, here, each of which corresponds to
> some idiom that I expect to be fairly common:
>
> 1. Use the path value directly. Its existence is taken for granted, so
> failing to exist is an error.
"taken for granted" should read "expected"
> 2. Test the existence of the path. The canonical case here is
> tal:condition="path:(exists)a/b/c", where the statement tag contents
> only make sense if 'a/b/c' exists.
>
> 3. Use the path value if it is true, otherwise leave the default in
> place. The path's existence is taken for granted (a ZClass property,
> for instance), so failing to exist is an error.
see #1
> 4. Use the path value directly, but leave the default in place if the
> path doesn't exist. The canonical case here is tal:replace="path:(if
> exists) request/foo", which replaces the tag even if the submitted text
> is blank or leaves the default value in place if the request did not
> contain 'foo'.
This is the behaviour I want.
I kinda like renaming "if" to "use-if". More explicit. "use-if exists" or
"use-if-exists" don't look too bad to me...
Richard
--
Richard Jones
richard@bizarsoftware.com.au
Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)