On Oct 13 2018, at 9:39 am, Anthony <[email protected]> wrote:
>
> Yes, but in your post, you indicated that when adding db to current in the 
> model file, it must be done inside a function rather than at the top level of 
> the model file, and that is not true. In the model file, you can do:
>
> from gluon import current
> current.db = db
>
>
>
> There is no reason to put those two lines inside a function in the model and 
> then call the function.
It is true Anthony, but i have always considered as a good practice keeping the 
globals clean of unwanted imports and definitions, so in the models i tend to 
do:
def _():
# import's, vars, even define_table calls without
# poluting globals
...
_() # call the anonymous function
Witch i think is a great way to go around, i think.
>
> 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] 
> (mailto:[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