Re: [web2py] Re: Current.db

2018-10-13 Thread Anthony
> > 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 ano

Re: [web2py] Re: Current.db

2018-10-13 Thread Yoel Benitez Fonseca
On Oct 13 2018, at 9:39 am, Anthony 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

Re: [web2py] Re: Current.db

2018-10-13 Thread Anthony
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

Re: [web2py] Re: Current.db

2018-10-13 Thread Lovedie JC
After removing the "db = DAL('sqlite://store.sqlite',migrate=False) " at the top of the module , the error disappears. Regards. On Fri, 12 Oct 2018, 23:59 Yoel Benitez Fonseca wrote: > In a model do, in db.py at the end if u can: > > def _(): > > from gluon import current > > current.db