Yes, thanks, Simone cue me about the on_define argument... I wasn't know
about that shame on me...

:)

Richard

On Wed, Mar 15, 2017 at 1:48 PM, Anthony <[email protected]> wrote:

> On Wednesday, March 15, 2017 at 12:03:52 PM UTC-4, Richard wrote:
>>
>> We can even use a set inside an IS_IN_DB() requires inside model
>> definition something like that prevent model from being lazy :
>>
>> db.define_table('tablename',
>>                              Field('fk_id_field', 'reference othertable',
>>                                        requires=IS_IN_DB(db(db.othert
>> able.id > 0), 'othertable.id', '%(represent_field)s')
>>                                        )
>>                              )
>>
>> This is sad...
>>
>> I confirm that
>>
>> some_set = db(db.tablename.fieldname > 1)
>>
>> put in model outside of table definition prevent the table over which the
>> set point from being lazy...
>>
>> And use of set inside IS_IN_DB() also prevent table from being lazy
>>
>
> The point of lazy tables is that they are not fully defined until you 
> *reference
> *them (i.e., via db.mytable or db['mytable']). Of course, once you
> reference them, they must be defined. If something like db.tablename.fieldname
> > 1 would not trigger a table to be defined, what exactly would you
> expect to trigger the definition?
>
> Anyway, the exact case you mention is covered by the on_define
> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#on_define>
> argument.
>
> If you want to improve performance related to model instantiation, you
> should also consider conditional models as well as moving some model
> definitions to modules.
>
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to