[ZPT] Re: ZPT digest, Vol 1 #262 - 4 msgs

Wade Leftwich wade@okaynetwork.com
Mon, 29 Oct 2001 13:26:22 -0500


I have not been able to write to ZSQL result records in Python scripts either; but I didn't try very hard.
Here's what I do instead:
#############
D = {}
result = container.theQuery()
names = recset.names()
L = []
for r in result:
    rec = {}
    for name in names:
        rec[name] = r[name]
    # here's your opportunity to change or add fields
    myfun(rec)
    L.append(rec)
D['recset'] = L
return D
############

>From the point of view of a PT, a list of dicts is just like a ZSQL result. [Except it lacks names() and data_dictionary() methods.]

Wade Leftwich
Ithaca, NY



>From: "Scott Murawski" <azbok@hotmail.com>
>To: zpt@zope.org
>Date: Sun, 28 Oct 2001 14:24:30 -0500
>Subject: [ZPT] Changing a returned item from a Z SQL Method in ZPT?
>
>I'm calling a Z SQL Method and retrieve one row.  Then I want to clobber one 
>of the returned items, specifically the item 'Order' in the oneRow variable.
>
>Its is possible to change the value of the Order item using some sort of ZPT 
>statment?
>
><TR TAL:define="oneRow python:here.FINDOneRow(ID=0);
>                dummy python:oneRow['Order']=5;">
>
>Its like no matter what I try, I get a syntax error because of the single 
>equals sign.
>
>Thanks greatly for any help or suggestions.
>
>