[web2py] Re: json - Not Serializable error
I must add that the below code are working when as a normal function that means def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy is OK But @service.json def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy is NOT OK On Tuesday, August 21, 2012 10:37:56 PM UTC+8, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: json - Not Serializable error
Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: json - Not Serializable error
I have just grabbed a copy of trunk about 12 hours ago. I have just grabbed it again 5 mins ago. Now it won't even let me access the page? I'm quite confused. It doesn't even generate a ticket... On Safari it says the operation cannot be completed. On Tuesday, August 21, 2012 10:54:46 PM UTC+8, Massimo Di Pierro wrote: Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: json - Not Serializable error
To clarify my abve post, I am using this code, and it fails without a ticket: def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy And I get a not serializable when I use this code @service.json def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy On Tuesday, August 21, 2012 10:54:46 PM UTC+8, Massimo Di Pierro wrote: Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: json - Not Serializable error
OK, I finally got it to work. Use db(db.table.id0).select().as_list() OR perform an Object update instead rows.__dict__.update(r) If there are better (or more correct/faster ways) to perform this behavior, I welcome your guidance and feedback. Thanks! On Tuesday, August 21, 2012 11:26:18 PM UTC+8, lyn2py wrote: To clarify my abve post, I am using this code, and it fails without a ticket: def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy And I get a not serializable when I use this code @service.json def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy On Tuesday, August 21, 2012 10:54:46 PM UTC+8, Massimo Di Pierro wrote: Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --