Am 1.12.10 14:52 , schrieb Tres Seaver:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 12/01/2010 08:27 AM, Andreas Elvers wrote:
Hi,
I stumbled over the following error using Zope 2.12.13. Bug ?
Given some ZSQLMethod, and either ZMySQLDA (3.1.1) or ZPsycopgDA (2.0.14 or 2.2.2) and the following python script:
result = context.someZSQLMethod() for row in result: for col in row: #this will fail pass
I get an AttributeError: __iter__
Traceback (innermost last): Module ZPublisher.Publish, line 127, in publish Module ZPublisher.mapply, line 77, in mapply Module ZPublisher.Publish, line 47, in call_object Module Shared.DC.Scripts.Bindings, line 324, in __call__ Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec Module Products.PythonScripts.PythonScript, line 344, in _exec Module script, line 3, in someZSQLMethod -<PythonScript at /testfolder/somePythonScript> - Line 3 Module AccessControl.ZopeGuards, line 181, in next Module AccessControl.ZopeGuards, line 211, in guard Module AccessControl.SecurityManagement, line 21, in getSecurityManager AttributeError: __iter__
I don't think the Record class fills the 'tp_iter' slot. Does the following workaround help?
result = context.someZSQLMethod() for row in result: for i in range(len(row)): col = row[i[
Yep. That one is working. Although that makes the planned upgrade from Zope 2.10 to 2.12 a real pain because I use a lot of the following : result = context.someZSQLMethod() names = result.names() dataForTemplate = dict(zip(names,result[0])) dataForTemplate['addingSomeMoreData'] = 'datadata' return context.comeTemplate(data=dataForTemplate) When did the iteration feature go away ? Must have missed the deprecation process. - Andreas