[Zope] HOw Do I Modify A Defined Variable In TAL?

Ed Leafe ed at leafe.com
Sat Aug 23 06:09:05 EDT 2003


On Thursday, August 21, 2003, at 06:16  PM, Jonathan Mark wrote:

> Using TAL and ZPT, I would like to define a global
> variable myVar, and then later on in the page
>
> add 1 to myVar, e.g.  myVar = myVar + 1.
>
> How can I modify a variable in TAL? I know how to
> modify a tag using REPLACE, ATTRIBUTES etc., but I
> want to modify a variable that I have previously defined.

	Just re-define the variable in terms of the old one. Here's a quick 
example:

<div tal:define="xx python:4">
This is the original: <span tal:replace="xx">orig</span><br>
This is the new: <span tal:define="xx python:xx*2" 
tal:replace="xx">orig</span><br>
</div>


      ___/
     /
    __/
   /
  ____/
  Ed Leafe
  http://leafe.com/
  http://opentech.leafe.com




More information about the Zope mailing list