[Zope] Quick question about <dtml-if ...>

hans hans@beehive.de
Wed, 08 May 2002 14:19:28 +0100


"George M. Ellenburg" wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Thanks to everyone for pointing me in the right direction the other day.
>
> I have a quick question regarding <dtml-if ...>  (I'm up to Chapter 4 in the
> Zope Book right now.)
>
> If I have a URI like this:
>    GET /foo?a=3
>
> And the corresponding DTML contains:
>
> <dtml-if expr="a=3">
>   <!-- Some Junk -->
> </dtml-if>
>
> ....Wouldn't this evaluate the Python expression?

it does

> I've tried doing:
> <dtml-if a=3>
>   <!-- -->
> </dtml-if>
>
> But received a syntax error.
>
> So I guess my question is, I thought the expr argument brought the DTML script
> outside the scope of the website.  I'm not trying to call any external
> methods.
>
> Have I completely lost it now? ;-)  (Don't answer that, please.)

it took me some time to understand, but basically there are 2
different ways for name resolution. name=... is DTML searching,
expr="..." is python searching (everything in " " is python).
a name-attribute may consist only of one identifier (thats why syntax error!)
(in <dtml-if name=myid>, nonexistence is treated as falsehood).
check also
http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
--
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin  (software developer)           hans@beehive.de
beehive elektronische medien GmbH       http://www.beehive.de
phone: +49 30 847-82 0                  fax: +49 30 847-82 299