Where is Rows.response gone?

2 views
Skip to first unread message

rfx_labs

unread,
Nov 2, 2009, 5:42:51 AM11/2/09
to web2py-users
Hi Massimo,

many of my apps use code like this:

result = db().select(db.reference.id, db.reference.l, db.reference.a,
db.reference.b)
for i, l, a, b in result.response:
c.reference(("lab"), l, a, b)

With code from Trunk 1376 this is broken. How do I get the same result
now?


Regards Martin

mdipierro

unread,
Nov 2, 2009, 8:28:11 AM11/2/09
to web2py-users
It is gone.

Rows.response was an internal variable that stored raw db response and
was backend dependent.
It is gone for good. The new Rows is much faster, smaller and cleaner.

Technically this is not exactly a breaking of backward compatibility
because developers are not supposed to use Rows.response which is an
internal variable but are supposed to use Rows[i] instead (which
contains backend independent data).

What were you using response for? If you post an example, I can help
you move your code to the newest web2py.

Massimo

rfx_labs

unread,
Nov 2, 2009, 11:12:55 AM11/2/09
to web2py-users
Hi Massimo,

> because developers are not supposed to use Rows.response which is an internal variable
Maybe I have misunderstand something in the first version of your book
on site 146.

> What were you using response for?
Mainly to get custom dictionaries.

> If you post an example, I can help
> you move your code to the newest web2py.

The first example was in my first post:

> > result = db().select(db.reference.id, db.reference.l, db.reference.a, db.reference.b)
> > for i, l, a, b in result.response:
> >     c.reference(("lab"), l, a, b)

This could be rewritten like this:
for r in result:
c.reference(("lab"), r.l, r.a. r.b)

Second example:
where = (db.interface.socket == db.socket.id) & (db.interface.host ==
db.device.id)
user = db(where).select(db.interface.socket, db.device.netname)
for r in user.response:
netuser[r[0]] = r[1]

And this like that:
for r in user:
netuser[r.interface.socket] = r.device.netname

Well if I look to the new code it's much clearer what's going on here.

Martin

Reply all
Reply to author
Forward
0 new messages