[Zope] Help with iterating thru a list of objects

Peter Bengtsson mail@peterbe.com
Fri, 29 Jun 2001 11:46:32 +0200


Python Scripts are never overkill. The only disadvantage with replaceing
DTML logic with small Python Scripts is that the list of objects in the ZMI
become very long.

In DTML:
<dtml-call "REQUEST.set('prev_A','#notlikelytobe#')">
<dtml-in sql_query>
    <dtml-if "A == REQUEST['prev_A']">
        Do something
    </dtml-if>
    <dtml-call "REQUEST.set('prev_A',A)">
</dtml-in>

Or in the superior alternative (script):

prev_A= "#notlikelytobe#"
for rec in context.sql_query():
    if rec.A == prev_A:
         Do something
    prev_A = rec.A




----- Original Message -----
From: "Dario Lopez-Kästen" <dario@ita.chalmers.se>
To: <zope@zope.org>
Sent: Friday, June 29, 2001 11:22 AM
Subject: [Zope] Help with iterating thru a list of objects


Hello!

I need to display the results of an sql query and I need to compare the
value of field A in the current item with the value of field A in the
previous item, in order to display things correctly.

Doing this in a Python script seems overkill, since I only need to control
the display of things.

I have crancked upp a lot of info in the result of the query for
optimization reasons so changing the query is out of the question.

Any help is appreciated.

Thank you,

/dario

- --------------------------------------------------------------------
Dario Lopez-Kästen     Systems Developer  Chalmers Univ. of Technology
dario@ita.chalmers.se  ICQ will yield no hits    IT Systems & Services



_______________________________________________
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 )