On 9 February 2012 15:45, Anthony <[email protected]> wrote: > I do not understand this properly. >> >> After explicitly importing 'current' in the controller, I made some >> progress. But why is the class definition necessary and how does it >> initialise db when db is not available in the module? >> > > You don't necessarily need a class. The point is just that you need to > pass in the db instance, either via an __init__ method of a class, or > simply as an argument to your function. In your case: > > def number_of_records(db, table): > > And when you call that function, pass in your db object as the first > argument. Another option is to add the db object to "current" -- for > example, in the db.py model file: > > from gluon import current > current.db = db > > Then when you import current in your module, you can refer to current.db. > > Thanks Anthony. That clears up a few things for me.
Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)

