In stable version there is a simpler way to define virtual fields. See this: http://web2py.com/examples/default/changelog
On Tue, Dec 18, 2012 at 9:26 AM, at <[email protected]> wrote: > Thanks for your reply; I am trying to use virtual fields but unable to fetch > records. > > my db.py defines: > db.define_table('taxpayer', > Field('enc_name'), > Field('age'), > Field('married', 'boolean'), > Field('spouse_name'), > Field('occupation')) > > class MyVirtualFields(object): > def name(self): > return myaes.decrypt(self.taxpayer.enc_name) > > db.taxpayer.virtualfields.append(MyVirtualFields()) > > (where myaes.decrypt is a function defined in myaes module) > > In the following code how can I access virtual field name? In record_list I > dont find name. > myorder = db.taxpayer.id > queryset = db(db.taxpayer) > record_list = queryset.select(db.taxpayer.ALL, orderby = myorder) > > Thanks & Regards, > > > > On Friday, 14 December 2012 19:38:28 UTC+5, viniciusban wrote: >> >> I think the most simple option in your situation is use computed fields. >> >> But if you really need to use a SQL function, you should write your >> query by hand. >> >> >> >> On Thu, Dec 13, 2012 at 3:48 PM, at <[email protected]> wrote: >> > >> > Hi, >> > >> > Lets say we've a table with name taxpayers; it contains 5 fields. Out of >> > these 5, two start with ar_. >> > What I want is to run some special function (say convertme() ) on these >> > two >> > fields starting with ar_ , while fetching data through DAL, like: >> > >> > query = (db.taxpayers.id > 10) >> > result = db(query) >> > >> > Can we somehow override the above method in a way that it would run the >> > following query: >> > select field1, field2, convertme(ar_field3), field4, >> > convertme(ar_field5) >> > from taxpayers where id > 0 >> > >> > Thanks in advance. >> > >> > >> > -- >> > >> > >> > > > -- > > > --

