[Zope] Global Variable In PT

Dieter Maurer dieter at handshake.de
Fri Aug 24 13:35:30 EDT 2007

tonylabarbara at aol.com wrote at 2007-8-23 13:47 -0400:
> ...
>I have this code (editing out the extraneous) at the beginning of a page:
><body bgcolor="#ffffff" 
>      tal:define="newRow string:yes">
>After calling some other variables (specifically rotating through a changing ¨item¨ (for item in items...)), I try and change newRow:
><span tal:define="global newRow item/newRow" tal:omit-tag="" />
>Then I try and call newRow:
><p tal:replace="newRow" />
>But it gives me the original value. Now, if I edit the page like this:
><span tal:define="global newRow item/newRow" tal:omit-tag="">
><p tal:replace="newRow" />

This means, you already have found a solution to your problem:

  Use "global" consistently for your variables.

I think, I also have read a specification how "global" and "local"
definitions for the same variable interact. When I remember right (but
I am not sure), then what you is is consistent with the specification.


More information about the Zope mailing list