ER: [Zope] Using ZSQL Results in python: "dictionaries" property doesn't exist

Steve Spicklemire steve@spvi.com
Wed, 20 Feb 2002 18:29:37 -0500


Hi Igor,

	Hmm.. the "dictionaries" method is pretty simple. You could 
probably implement it yourself.

	Create a Python Script, and make its only parameter the results 
from you ZSQLMethod called "results" and do:

         r=[]
         a=r.append
         names=results.names()
         for row in results:
             d={}
             for n in names: d[n]=row[n]
             a(d)

         return r

(basically stolen from Results.py of lib/python/Shared/DC/ZRDB)

-steve

On Wednesday, February 20, 2002, at 02:09 PM, Igor Leturia wrote:

>   You're right, Dieter, I'm using ZODBCDA. So now, to solve my problem I
> need to do do one of these two things:
>     1) Solve the bug in ZODBCDA, which I don't think I am capable of. 
> Could
> you or anyone give me some help on it?
>     2) Use  whatever ZODBCDA uses instead of dictionaries (I suppose 
> Results
> returns the records in some field with another name). Does you or anyone
> know the name of the field ZODBCDA uses instead of dictionaries? Or is 
> there
> a way to know the properties or fields of an object in Python? If there 
> is,
> then I would use it to get the public properties or fields of the 
> Results
> object and then I could try and see which of them holds the records of 
> the
> query.
>   Thanks in advance,
>
>                             Igor Leturia
>
>> Igor Leturia writes:
>>>   I am trying to use the "Results" variable returned by any ZSQL 
>>> method
>>> in a python script, as shown in this how-to:
>>> http://www.zope.org/Members/spinwing/ZSQL_Results . The thing is I can
>>> access Results.names() and Results.data_dictionary() as shown in the
>>> examples there, but not Results.dictionaries(). It says that the
>>> property doesn't exist.
>> Due to a bug, some database adapters (notably ZODBCDA) use
>> a variant of the "Results" class that does not support
>> "dictionaries"...
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )