[Zope] More REQUEST.set() not incrementing
Jeff K. Hoffman
jeff@goingv.com
Tue, 11 Jan 2000 17:32:38 -0500 (EST)
On Tue, 11 Jan 2000 Jerry.Spicklemire@IFLYATA.COM wrote:
> Hi again,
>
> No response to my first distress call, so I thought maybe some more details
> would help.
>
> When I insert some print commands, the assigned "counter" (u_*) variables
> exist, but are reported as being equal to zero (0). So, it appears that the
> original assignment is "taking".
>
> Except that when I look at all of the variables by printing <dtml-var
> REQUEST>, the same variables appear as being equal to one (1), so it seeems
> like the incrementing is happening.
>
> Except that, the number never increases beyond one, so that it seems that
> what appeared to be incrementing was really just re-setting the variable to
> zero plus 1 (0 + 1), as if each pass through the loop is refreshing the
> values to the original assignment.
I tried this:
<dtml-let i="0">
<dtml-in "_.range(100">
<dtml-call "REQUEST.set('i', i + 1)">
<dtml-var i>
</dtml-in>
</dtml-let>
and got:
0 0 0 ... 0
Then, I changed it to:
<dtml-call "REQUEST.set('i', 0)">
<dtml-in "_.range(100)">
<dtml-call "REQUEST.set('i', i + 1)">
<dtml-var i>
</dtml-in>
and got:
1 2 3 ... 100
I haven't had a chance to peer into the code and see how let is
implemented, yet, but it is my guess that dtml-let is defining the
variable in the *local DTML namespace*, and REQUEST.set('i', i + 1) is
setting the value of 'i' in *the request* to the local value of i plus 1
each time through the loop, thus always outputting 1. Initializing i with
a simple <dtml-call "REQUEST.set('i', 0)"> makes the inside of the loop
uniformly access 'i' in the REQUEST.
Of course, I could be wrong. :)
> Thanks for looking at this silly thing,
Hope this helps!
> Jerry S.
--Jeff
---
Jeff K. Hoffman 704.849.0731 x108
Chief Technology Officer mailto:jeff@goingv.com
Going Virtual, L.L.C. http://www.goingv.com/