I think you won't notice any difference in the performance. 
If you care about that query, you don't have to worry, because the query 
will only be executed when the field needs to be rendered (in a form), or 
in the moment of the validation (when submitting the form). 

So I would say that you leave those lines in the model. For mantainance and 
debugging purposes, it will be more practical to keep all database 
definition and restrictions in the model/s file/s. 
The only reason I can imagine to put that requires in the controller is if 
you have different requires in different controller/functions for the same 
db field.

Hope that helps.


El miércoles, 15 de abril de 2015, 14:50:34 (UTC-3), Alex Glaros escribió:
>
> Here is a regular requires is_in_db statement:
>
>
> gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)
>
> db.GovOrgJurisdiction.organizationID.requires = 
> IS_IN_DB(db(gov_org_query), 'Organization.id', 
> '%(organizationFullName)s',zero=T('choose one'))
>
>
> is it more efficient to put these two in the controller so they are called 
> only when used?
>
> I don't understand if they would get executed needlessly if placed in the 
> model if the function that needs them is not used for many sessions
>
> thanks
>
> Alex Glaros
>

-- 
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