[ZPT] REQUEST argument

marc lindahl marc@bowery.com
Mon, 14 May 2001 03:10:11 -0400


> From: Guido van Rossum <guido@digicool.com>
>
> Apparently (I haven't written much DTML either ;-) in DTML a common
> idiom is:
> 
> <dtml-if foo>
> <dtml-var foo>
> </dtml-if>
> 
> which substitutes foo only if it exists and is non-empty, and Jim
> claims that this is useful.


Yeah, and the thing I can't still come to terms with is, what if 'foo'
exists, but according to Permissions, you're not allowed to 'access contents
information' or 'view'?  You're thrown an exception!  Perhaps if
'skip_unauthorized' would work in dtml-if and/or dtml-var....


> 
> How would one write DTML that substitutes foo if it exists, regardless
> of whether it is empty?

That's a construct I'm still trying to figure out!

<dtml-if foo>
<dtml-var foo>
<dtml-else>
<dtml-let foo="whatever">
</dtml-let>
</dtml-if>

but usually you want the </dtml-let> outside the </dtml-if>.  If it was
straight interpret-as-you-go that would work, but it doesn't....


> So maybe that's the crux of the matter: <dtml-if> is really abused to
> test for existence, and the fact that it also test for non-emptiness
> is not required but neither is it harmful.

What else could it test for?  Conceptually the set of "true" is "something
not zero" which excludes both nothing and zero (or existing empty sets)

> but what makes
> it useful in this case is the fact that undefined values are
> considered false rather than raising an exception (like they do in
> Python).

Don't undefined values raise an exception only where they cause some kind of
conflict, in Python?

> 
> Using a C preprocessor analogy: DTML has #if but not #ifdef, so we're
> making #if do the work of #ifdef -- which usually works.

Actually, seems like python's if == (CPP#if or CPP#ifdef), no?  Anyway, why
bother relating it to C, unless you're writing a library?



...blather...it's late....