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

2010-12-08 Thread Andreas Elvers
Am 7.12.10 15:19 , schrieb Tres Seaver:

>>
>> result = context.someZSQLMethod()
>> for row in result:
>>  for col in row: #this will fail
>> pass
>
> Does the "safe list" builtin work for you in 2.12?
>
>for row in result:
>for col in list(row):
>pass
>
>

Yes. This works in 2.12.

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-07 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 12/07/2010 09:19 AM, Tres Seaver wrote:
> On 12/07/2010 05:02 AM, Andreas Elvers wrote:
>> To answer part of my own question:
> 
>> ZSQLMethod  column iteration went away with 2.12. Up until Zope 2.11.7 
>> still had this feature available with no deprecation messages logged 
>> when using this feature.
> 
>> Should I file a bug for missing deprecation messages in 2.11 or for 
>> missing functionality in 2.12 ?
> 
> Hmmm, I would file it as missing functionality in 2.12.  The bug may be
> due to changes in the supported version of Python (2.4 for Zope < 2.12,
> 2.6 for 2.12).

The attached script should help isolate the bug without needing an
actual SQL connection.  Under 2.11, run as::

 $ PYTHONPATH=lib/python /path/to/python2.4 iter_results_record.py

Under 2.12, run as::

 $ bin/allpy iter_results_record.py

Note that the script runs without errors under both versions for me:
likely the security machinery isn't actually being wired up.  I'm out of
time, however, to think harder about it.



Tres.
- -- 
===
Tres Seaver  +1 540-429-0999  tsea...@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/

iEYEARECAAYFAkz+UdoACgkQ+gerLs4ltQ7rPwCguzHh/nFv1hexflrJkNDl/YEI
OL0AoMsiIAv/p647aaACgvieRDhiUPRx
=6YB9
-END PGP SIGNATURE-


iter_results_record.py
Description: application/httpd-cgi
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-07 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 12/07/2010 05:02 AM, Andreas Elvers wrote:
> To answer part of my own question:
> 
> ZSQLMethod  column iteration went away with 2.12. Up until Zope 2.11.7 
> still had this feature available with no deprecation messages logged 
> when using this feature.
> 
> Should I file a bug for missing deprecation messages in 2.11 or for 
> missing functionality in 2.12 ?

Hmmm, I would file it as missing functionality in 2.12.  The bug may be
due to changes in the supported version of Python (2.4 for Zope < 2.12,
2.6 for 2.12).



Tres.
- -- 
===
Tres Seaver  +1 540-429-0999  tsea...@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/

iEYEARECAAYFAkz+QoAACgkQ+gerLs4ltQ7wMwCg1p4q1uBIk3BVWpDPU3fyx2dU
cVYAnAjA+JzC9W+q5VPlDyXUMOIEHA6l
=CNid
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-07 Thread 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

Does the "safe list" builtin work for you in 2.12?

  for row in result:
  for col in list(row):
  pass



Tres.
- -- 
===
Tres Seaver  +1 540-429-0999  tsea...@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/

iEYEARECAAYFAkz+QnwACgkQ+gerLs4ltQ5kmQCfdzh17HxciJxRhr2oQwkxqrcL
ewkAoNc4bvQ/mI5fEq1xkrmn9bPiVWzA
=ZEge
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-07 Thread Andreas Elvers
Hi Tres,

[...]
>> 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__

[...]

> I don't think the Record class fills the 'tp_iter' slot.  [...]

I don't know about this tp_iter slot, but adding the following
DocTest to the Record tests.py will pass:

def test_RecordIteration():
 """

 Creating a record

 >>> r = P(('zx', 81 , 1.23))

 We can iterate over a record:

 >>> [i for i in r]
 ['zx', 81, 1.23]

 """

- Andreas

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-07 Thread Andreas Elvers
To answer part of my own question:

ZSQLMethod  column iteration went away with 2.12. Up until Zope 2.11.7 
still had this feature available with no deprecation messages logged 
when using this feature.

Should I file a bug for missing deprecation messages in 2.11 or for 
missing functionality in 2.12 ?

- Andreas

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-01 Thread Andreas Elvers
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
>>  -
>>  - 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

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-01 Thread 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
> - 
> - 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  tsea...@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-

___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


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

2010-12-01 Thread Andreas Elvers
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
- 
- 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__

- Andreas



___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )