[Zope] <dtml-let> syntax
Dieter Maurer
dieter@handshake.de
Fri, 20 Apr 2001 21:52:05 +0200 (CEST)
Sebal writes:
> <dtml-let x=fmod(sequence-index,4))>
Three standard problems:
1. attribute values for "let" that are not enclosed in "..."
are treated as names and looked up:
the code above tries to look up an object with
name "fmod(sequence-index,4))" - quite hopeless
You an expression rather than a name, enclose in "..."
2. "sequence-index" is a valid DTML name but it is invalid
in Python. More precisely, it is interpreted there
as "sequence - index", a subtraction not a name.
You need "_['sequence-index']"
3. I never saw "fmod". Is it a Python built-in?
Anyway, even if it were, it would not be available
in DTML. (Some) Python built-in are available
as attributes of "_". Other built-in functions
are not available.
After this didactic excursions, a short answer to your question:
<dmtl-let x="_['sequence-index'] % 4 == 0">
"%" (applied to numbers) is Python's "mod" operator.
Dieter