[Zope] dtml-in

Thomas B. Passin tpassin@mitretek.org
Tue, 7 May 2002 15:15:59 -0400


[D. Rick Anderson]

> I'm using <dtml-in "_.range(31)"> to loop. What I can't seem to do is
> use the sequence-number to compare to anything. Is there a special wat
> that it needs to be reffered to? This is what I'm doing:
>
> <dtml-if "variable == sequence-number">
>
> but it keeps error out with:
>
> *Error Type: NameError*
> *Error Value: global name 'sequence' is not defined*

Yes, that's a common thing.  What's happening is that the expression is
being evaluated by Python (all expressions in quotation marks are), but
Python does not use a minus sign in variable names and so tries to subtract
"number" from "sequence".

The usual work-around is to use the alternative form:

<dtml-if "variable=_['sequence-number']">

This way, you can get any attibute of the current Zope namespace by name,
minus signs or not.

Cheers,

Tom P