Yes. The values of virtualfields are not stored in the database. They are computed every time a record is extracted.
In the above case the values are computed when a record is inserted and they are stored in the database. In RDBS this is not really a good idea but you may need it in non relational DBs like GAE. Massimo On Dec 27, 5:30 pm, Mengu <whalb...@gmail.com> wrote: > is there any difference with this and our virtualfields? > > On 28 Aralık, 00:39, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > It was easy to add it to the current DAL (will work on GAE too) > > > massimo-di-pierros-macbook:web2py mdipierro$ python web2py.py -S > > welcome>>> db=DAL('sqlite://storage.sqlite') > > >>> db.define_table('a',Field('b'),Field('c',compute=lambda r: > > >>> r['b'].lower())) > > >>> db.a.insert(b='HELLO') > > >>> for row in db(db.a.id>0).select(): print row.b, row.c > > HELLO hello > > >>> db(db.a.id>0).update(b='WORLD') > > >>> for row in db(db.a.id>0).select(): print row.b, row.c > > > WORLD world > > > On Dec 27, 4:16 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > This thread > > > >http://groups.google.com/group/google-appengine-python/browse_thread/... > > > > raises an interesting issue and proposes an interesting solution that > > > works on GAE. > > > > Executive summary: In GAE you can define computed fields that are > > > computed now when data is extracted but when data is stored and the > > > computed fields are stored too. Why? Because you can use them to > > > perform operation that would otherwise not be supported on GAE. > > > > It would be trivial to support this in web2py and make it cross-db. > > > Basically all we need is a new field attribute that points to a > > > function that computes the value of a field based on the values of the > > > other fields. We already have this db.table.field.update and it can be > > > a function. > > > > I think the new DAL should support this. > > > > Massimo > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.