On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:
>
> Thank you very much for the quick answer.
>
> Your first comment made me think about the "lazy_tables" with the 
> definition of virtual method fields.
> If you say that doing db.tablename the table is no longer lazy, *then it 
> wouldn't make sense to use lazy_tables in a particular case where almost 
> each table has a virtual method field, am I right?*
>
> I mean, for example, if this is my model:
>
> db.define_table('first_table', Field('field1'), Field('field2'))
>
> db.first_table.field3 = Field.Method(lambda row: 'value for field3')
>

This won't help with db.auth_user, which is defined automatically (though 
you can define it manually yourself if preferred), but you can simply do:

db.define_table('first_table',
                Field('field1'),
                Field('field2'),
                Field.Method('Field3', lambda row: 'value for field3'))

Note, the first argument of Field.Method() and Field.Virtual() should 
always be the field name anyway, even if you are defining them like this:

db.mytable.myfield = Field.Method('myfield', ...)

There are particular cases where leaving the name out can lead to problems.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to