[ZPT] TAL Exists: type

Martijn Pieters mj@digicool.com
Wed, 21 Mar 2001 17:14:18 +0100


On Wed, Mar 21, 2001 at 11:08:41AM -0500, Todd Coram wrote:
> If exists: checks for the existence of objects (derived from paths), how do
> we distinguish "hard" traversal errors from "soft" ones? What does it mean
> to say "testing for whether and object exists or not" when traversal is
> dynamic? What if the act of traversal causes behavior (hit count increment,
> random redirection, etc)?
> 
> Martijn's example:
> 
> > <div tal:condition="exists:request/statusMessage"
> >      tal:content="request/statusMessage">
> >      The optional status message will be displayed here
> > </div>
> 
> is on the mark. This is a fairly simple traversal with obvious semantics.
> But, how about:
> 
> <div tal:condition="exists:here/yourCountry/yourState/yourCity/zopeContact">
> 
> Okay, so this could return true if your "home" city has a zope contact
> person, otherwise false if there is no zope contact in that city.  But, what
> if there is a traversal error (i.e. calling one of the elements results in a
> "system" error)? Maybe "yourState" is broken.  What is the correct behavior?
> Does exists: catch exceptions and silently return false?

I'd say exists should only return false on key and attribute errors;
specifically where the error message names an item on the path. This is
how dtml-if works as well.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------