Thanks, Jonathon, Does that mean there's only one instance of current for a running instance of Web2py? So if I do current.db, it could overwrite a current.db assigned in an earlier request?
On Thursday, June 7, 2012 7:07:35 PM UTC-4, Jonathan Lundell wrote: > > On Jun 7, 2012, at 2:42 PM, Cliff Kachinske wrote: > > I don't have a good feel for the most efficient way to, for example, pass > the db to a class method. I can think of three ways. > > - Pass it in when you call the method. > - Pass it in when you initialize the class > - Import current, do something like current.db = db and then pass current > to the class's __init__ > > Any opinions on this? All help greatly appreciated. > > > It shouldn't really matter. But where is the caller and callee? If the > caller is in a controller and the callee is in an imported module, for > example, I don't think it makes much difference. I'd avoid current where > you don't really need it (and if you do use current, using current.db is a > little risky; try to give yourself a safe namespace). >