[Zope] dtml-let help

Dieter Maurer dieter@handshake.de
Sat, 27 May 2000 01:12:31 +0200 (CEST)


Pete Kazmier writes:
 > I'm trying to keep a cumulative count while sequencing over a list via
 > the dmtl-in tag.  I tried this but it didn't work, Zope complained
 > about the syntax....
 > 
 > <dtml-let totalActive="0">
 > 
 > <dtml-in "objectValues(['Gateway'])">
 >   <dtml-with sequence-item>
 >     <dtml-var "totalActive=totalActive+active">
 >   </dtml-with>
 > </dtml-in>
I can tell you, why you get the syntax error.
Luis Cortes has told you, how you could do your job.


Explanation:
  Python distinguishes between expressions which can be "eval"ed
  and commands which can be "exec"ed.
  Assignments are commands, as are definitions, if, for, while constructs.

  Zope uses "eval" to evaluate expressions in DTML-tags.
  "eval" raises a SyntaxError when confronted with a command.

Dieter