[ZPT] Possible changes to path-related
Evan Simpson
evan@digicool.com
Mon, 30 Apr 2001 23:51:17 -0500
From: <richard@bizarsoftware.com.au>
> Ow, that was quick turnaround on major changes to the proposal.
I felt an unaccountable need to get this feature into 1.2, and 1.2 was
getting well overdue. I now regret rushing. I understand the
uneasiness you and others have expressed with this syntax, but until we
have an "Aha!" moment and come up with something much better, I'd like
to try to press forwards.
> 'if' means one thing by itself.
> 'exists' means one thing by itself. 'if exists' means something
> again (even if similar). What does 'exists if' mean?
The same as 'if exists'. It really doesn't care what order the
modifiers appear in, just what combination.
> Do you have a use case for the above definition of the behaviour of
"if request/foo"?
Suppose you has a ZClass which had properties to control the rows,
columns, and content of a textarea. The rows and columns properties
always exist, but if they are blank (false) you want to omit the
textarea attributes, or leave them set to some default. Not critical,
but plausible, I think.
The 'nocall' modifier can be usefully combined with either 'if' or 'if
exists', since they both return the value of the path.
> that this new mechanism doesn't actually work.
Yes, it's broken - thanks for the Tracker patch!
> Also, lazy: didn't care about the actual value returned - this is
important
> for the example above if the request has an empty string value in it
That's 'if exists'. It only cares if the path exists. If you care
about the value, you use 'if'.
> <input type="checkbox" tal:condition="(if) request/form/foo"
CHECKED>
> <input type="checkbox" tal:condition="(if) not:request/form/foo">
I think that you want the form:
<input type="checkbox" tal:attributes="checked (if exists)
request/form/foo">
This will set the 'checked' attribute if and only if 'request/form/foo'
exists and is true. Using '(exists)' would set it when the path exists,
regardless of value. Using '(if)' sets the attribute when the value
exists and is true, but raises an error if it doesn't exist. This form
has the virtue of showing in a WYSIWYG editor as a single checkbox,
rather than a pair of them.
> It also seems that one can't do the equivalent of
> "not:exists:" any more. Nor "not:if:".
The first is spelled "not: (exists)". The second is "not: (if)", though
it is a bit odd, since it either returns false, cancels the action, or
raises an error. "not: (if exists)" is also legal, and makes a bit more
sense, being like plain "not:" except for cancelling when the path
doesn't exist.
> p.s. The zpt mailing list archive is still broken... Any hope of a fix
there?
I'm not sure what's going on there; I'll ask our list admin.
Cheers,
Evan @ digicool