On Monday 15 August 2011 19:47:09 pbreit wrote:
> I think you might have to dereference r. Something like r[0].odo since
> queries return a set even if there's only one element.
From my tests, the .first() in the query:
> r = db(q).select(db.trip.odo, orderby=o, limitby=(0,1)).first()
seems to return only one Row. This is confirmed where r is returned by the
distance function in a tuple:
> return (d, self.trip.odo, r) # Return extra info to see problem
and then printed out in the test loop:
> 2011-01-03 | 1300 | (0, 1200, <Row {'odo': 1200}>)
Here the tuple at the end is the return value from the distance function, with
r the row selected in the virtual function, showing thaqt the selected row odo
value is 1200. The second value in the tuple is supposed to be the trip.odo
value of the record passed into the virtual function (should be 1300 in this
case shown as the second field printed), but inside the virtual function,
after doing a select for the previous row, *self* seems to be *replaced* by
the select result.
It's almost like a buffer is being overwritten when doing a select in the
virtual field function which causes the original record passed into the
function to be lost.
Thanks for your reply though.
/Tom