Crashes in shell too: >>> rows = db(db.products.id>0).select() >>> class virtual(object): ... def test(self): ... return 'ok' ... >>> rows.setvirtualfields(virtual=virtual()) Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/brunomac/web2py_new_dal/web2py/gluon/dal.py", line 4471, in setvirtualfields if callable(method) and method.im_func.func_code.co_argcount: File "/Users/brunomac/web2py_new_dal/web2py/gluon/dal.py", line 3060, in __getattr__ return dict.__getitem__(self,key) KeyError: 'im_func' >>>
*But using the other way, the virtual field is appended only for the first row:* >>> db.category.virtualfields.append(virtual()) >>> db.category.virtualfields [<virtual object at 0x101a27410>] >>> rows = db(db.category.id>0).select() >>> >>> print rows[0] <Row {'picture': 'category.picture.9f4f39811d410b54.3634362d4c5f7468756d622e6a7067.jpg', 'description': None, 'update_record': <function <lambda> at 0x101d9f668>, 'products': <gluon.dal.Set object at 0x101d93bd0>, *'test': 'ok'*, 'id': 1, 'delete_record': <function <lambda> at 0x101d9f6e0>, 'name': 'Vegan Food'}> >>> print rows[1] <Row {'picture': 'category.picture.b1974a4805e47745.393733432d4c5f7468756d622e6a7067.jpg', 'description': None, 'update_record': <function <lambda> at 0x101d9f758>, 'products': <gluon.dal.Set object at 0x101d93c50>, 'id': 2, 'delete_record': <function <lambda> at 0x101d9f7d0>, 'name': 'Dairy Free Candy'}> >>> 2010/12/19 Bruno Rocha <rochacbr...@gmail.com> > > Crashes in *setvirtualfields *for Rows object > > sqlrows.setvirtualfields(virtual=virtualFields()) > > File "/Users/brunomac/web2py_new_dal/web2py/gluon/dal.py", line 4471, in > setvirtualfields > > if callable(method) and method.im_func.func_code.co_argcount: > > File "/Users/brunomac/web2py_new_dal/web2py/gluon/dal.py", line 3060, in > __getattr__ > > > return dict.__getitem__(self,key) > KeyError: 'im_func' > > > -- > > Bruno Rocha > http://about.me/rochacbruno/bio > -- Bruno Rocha http://about.me/rochacbruno/bio