column iteration regression

Bug #926278 reported by srepmub
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Products.ZSQLMethods
Invalid
Undecided
Unassigned

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:

http://comments.gmane.org/gmane.comp.web.zope.general/62973

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.

Revision history for this message
srepmub (mark-dufour) wrote :
Revision history for this message
srepmub (mark-dufour) wrote :

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

Products.ZSQLMethods-2.13.4-py2.7.egg/Shared/DC/ZRDB/Results.py:

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

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

Revision history for this message
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, self.data))
        row = ob[0]
        for col in row:
            pass

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

Revision history for this message
Andreas Elvers (itsafire1) wrote :

Is this really an Acquisition bug ?

Revision history for this message
Tres Seaver (tseaver) wrote :

Not an Acquisition issue. Reassigning.

affects: acquisition → products.zsqlmethods
Revision history for this message
Andreas Elvers (itsafire1) wrote :

Does the patch proposed by srepmub seem reasonable ?

Revision history for this message
Colin Watson (cjwatson) wrote :

The products.zsqlmethods project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/products.zsqlmethods.

Changed in products.zsqlmethods:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.