What's the status of the new VirtualFields design? The latest
I've seen is:
db.item.adder=Field.lazy(lambda self:self.item.a + self.item.b)
I have two design proposals:
(1) Instead of calling them "VirtualFields" and "Lazy VirtualFields,"
I think they should be "VirtualFields" and "Methods." Two
completely different things.
The primary usage of lazy virtual fields seems to be adding helper
methods to rows, so that one can call them as row.func() instead
of func_on_table(row). This is a "method," not a "virtual field."
(2) Put this API into db.define_table() instead of a separate set of
statements.
This puts all "objects you can access on a row" (Field,
VirtualField, ComputedField, and Method) in one place in your
code. And compared to separate class definitions, it reduces the
lines of code necessary.
Here's an example:
db.define_table('item',
Field('a', 'double'),
Field('b', 'integer'),
VirtualField('added',
lambda self: self.item.a + self.item.b),
Method('notify',
lambda self: send_email(self.item.a)))