[Zope] converting Dictionary to Result

Tino Wildenhain tino at wildenhain.de
Mon Jun 19 15:39:05 EDT 2006


Alric Aneron wrote:
> Hello,
> I have a dictionary object and a result set object (that was returned
> from a ZSQL method).  Is there any way I can merge them into one
> variable and use them in a dtml-in statement?

You should know which one should update which one.

So assuming your dictionary has to override/extent attributes
returned from ZSQL-Methods, you can write


res=context.yourZSQLMethod(args...).dictionaries() # see API docs
for item in res:
    item.update(yourdictionary)

return res

thats all.

The other way round could be:

res=context.yourZSQLMethod(args...).dictionaries()
return [dict(yourdictionary,**item) for item in res]

(see python docs about list comprehension and function
argument forms)

Regards
Tino


More information about the Zope mailing list