As for what you said, pbreit - this is acctually a copy paste of the book. The version installed is 1.97.1
As for your your 2nd suggestion >>> db.item.total_price.compute = lambda r: float(r['unit_price']) * >>> float(r['quantity']) >>> r = db.item.insert(unit_price=1.99, quantity=3) >>> r.total_price '5.97' >>> db.commit() >>> r.id 2 >>> db(db.item.id>0).select(); <gluon.dal.Rows object at 0x17f2450> >>> db(db.item.id>0).select()[1] <Row {'total_price': '5.97', 'update_record': <function <lambda> at 0x17f1c80>, 'unit_price': 1.99, 'id': 2, 'delete_record': <function <lambda> at 0x17f1cf8>, 'quantity': 3}> >>> >>> db(db.item.id==2).select()[0]; <Row {'total_price': '5.97', 'update_record': <function <lambda> at 0x17f1b18>, 'unit_price': 1.99, 'id': 2, 'delete_record': <function <lambda> at 0x17f1d70>, 'quantity': 3}> >>> db(db.item.id==2).update(quantity=12); 1 >>> db.commit() >>> db(db.item.id>0).select()[1] <Row {'total_price': '5.97', 'update_record': <function <lambda> at 0x17f1f50>, <Row {'total_price': '5.97', 'update_record': <function <lambda> at 0x17f1f50>, 'unit_price': 1.99, 'id': 2, 'delete_record': <function <lambda> at 0x17f7050>, 'quantity': 12}> So nothing yet... On Jul 14, 11:18 pm, pbreit <pbreitenb...@gmail.com> wrote: > That definitely looks like it should work according to the book. > > What do you get when you do it exactly like the book? > > >>> db.define_table('item', > > Field > <http://web2py.com/book/default/docstring/Field>('unit_price','double'), > Field > <http://web2py.com/book/default/docstring/Field>('quantity','integer'), > Field <http://web2py.com/book/default/docstring/Field>('total_price', > compute=lambda r: r['unit_price']*r['quantity'])) > > >>> r = db.item.insert(unit_price=1.99, quantity=5) > >>> print r.total_price > > What version of Web2py? Do you get different behavior if you pull the > compute out of the table def? > > db.item.total_price.compute = lambda r: r['unit_price']*r['quantity'] > > How about: > db.item.total_price.compute = lambda r: float(r['unit_price']) * > float(r['quantity'])