On Friday, October 12, 2018 at 5:16:10 PM UTC-4, Yoel Benitez Fonseca wrote:
>
> Sorry Anthony but it seems to that the original question was about 
> accesing db trough current, with is not set in current by default so my 
> answer is about that's.
>
> You need to set current.db in a models an in a module:
>

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.

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.

Reply via email to