[Zope] More REQUEST.set() not incrementing

Jim Sanford jsanford@atinucleus.com
Tue, 11 Jan 2000 18:15:15 -0600


This should work:

<dtml-call "REQUEST.set('i',0)">
<dtml-in "_.range(100)">
  <dtml-let j="i+1"
     <dtml-call "REQUEST.set('i', j)">
  </dtml-let>
  <dtml-var i>
</dtml-in>

I have never had consistent success using formulas in REQUEST.set
 __________________________________________________________________
 
              Jim Sanford
      .       Database Engineer
     / \  /   Accelerated Technology, Inc.
    /   /     720 Oak Circle Drive East
   /  /  \    Mobile, AL 36609
  / /     \   Voice: 334-661-5770  fax: 334-661-5788
 /         \  E-Mail: jsanford@atinucleus.com
              Web: http://www.atinucleus.com
  
 Source Code, No Royalties, Any CPU...It just make sense !
 __________________________________________________________________



----- Original Message ----- 
From: Jeff K. Hoffman <jeff@goingv.com>
To: <Jerry.Spicklemire@iflyata.com>
Cc: <zope@zope.org>
Sent: Tuesday, January 11, 2000 4:32 PM
Subject: Re: [Zope] More REQUEST.set() not incrementing


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/


_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )