[Zope] Iteration over columns in ZSQLMethod result not working in Zope 2.12.13

Tres Seaver tseaver at palladion.com
Wed Dec 1 08:52:16 EST 2010


-----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[



Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz2UxAACgkQ+gerLs4ltQ79tgCgvTqC6Kgsk60n7kUuh95FYfMQ
Gd0An2al8dDlrfKvLT+VIJw3ODGacigo
=YFm1
-----END PGP SIGNATURE-----



More information about the Zope mailing list