column iteration regression

Bug #926278 reported by srepmub on 2012-02-03
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

we make use of column iteration in about a 1000 places in our code, but at some point between our current version of zope (very old, using python 2.4) and 2.13.9 (using python 2.7), the feature seems to have broken:

for row in context.test_sql():
    for col in row:
        print col
return printed

this now gives:

Exception Type AttributeError
Exception Value __iter__

I don't see another bug filed for this, as was discussed here:

the program attached in this thread, which tests just Shared.DC.ZRDB.Results works however..

debug info is attached. this is for a clean zope install.

srepmub (mark-dufour) wrote :
srepmub (mark-dufour) wrote :

I have no idea if this will break other things, but adding __iter__ here at least fixes my test case:


      class r(Record, Implicit, brains, zbrains):
            'Result record class'

+ def __iter__(self):
+ return iter([self[i] for i in range(len(self))])

Andreas Elvers (itsafire1) wrote :

The bug is only triggered if the column interation takes place inside of a python script. When starting zope in debug mode and iterate over a record of an SQLMethod result "by hand" the Attribute Error is not triggered.

So this test:

    def test_column_iteration(self):
        ob = self._makeOne((self.columns,
        row = ob[0]
        for col in row:

added to Shared/DC/ZRDB/tests/ does not trigger the bug either.

Andreas Elvers (itsafire1) wrote :

Is this really an Acquisition bug ?

Tres Seaver (tseaver) wrote :

Not an Acquisition issue. Reassigning.

affects: acquisition → products.zsqlmethods
Andreas Elvers (itsafire1) wrote :

Does the patch proposed by srepmub seem reasonable ?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments