[egenix-users] Converting ZQL method return value to dictionary
Jerry Westrick
Jerry at Westrick.Com
Sun Aug 10 12:54:16 CEST 2003
WOW!
Thanks for the prompt responce!
I'll repost to the Zope....
Jerry
On Sun, 2003-08-10 at 11:49, M.-A. Lemburg wrote:
> Jerry Westrick wrote:
> > Hello:
> >
> > I'm not sure if this is the right list, if not sorry.
> >
> > I'm trying to convert the result of a Zql method into a dictionary.
> > the code I'm using is:
> >
> > # Get User Info
> > for row in context.Get_UserInfo(user=request.AUTHENTICATED_USER):
> > values['user'] = row
> >
> > The Get_UserInfo is a Z SQL Method, returning a single row
> > from a mxODBC conneciton.
> >
> > when I executed the following lines:
> >
> > print values['user']
> > return printed
> >
> > I get
> >
> > <r instance at 8d8f130>
> >
> > I would to convert this r instance to a dictionary, so I can add/modify
> > values in it like the following:
> >
> > values['user']['justforfun'] = 'Additional info not from select!'
> >
> > which at the moment gives me:
> >
> > Error Type: TypeError
> > Error Value: object does not support item or slice assignment
> >
> > Now to my questions:
> > 1) the class "r", is it a Zope thingy or a mxODBC thingy?
>
> It's a Zope thingy. mxODBC wraps the results as Zope Results
> instance which in return dynamically wraps rows as "r" instances
> which are subclasses of the Zope Record type.
>
> See lib/python/Shared/DC/ZRDB/Results.py for details.
>
> > 2) is there a mothod to do what I need?
>
> You should probably convert the r instance to a dictionary
> and then use that. The r instance does not support the
> full dictionary interface.
>
> In any case, the zope-db mailing list will probably give you
> better help.
>
> > Than you for your time...
> > Jerry
> >
> > P.S. There are other dictionary functions not support by this "R"
> > instance that I would like to use also...
More information about the egenix-users
mailing list