[web2py] Access db in module

2013-07-05 Thread Remco K
Hi all, I have a class in modules from which i can't access the DB object. I have this: in models/db.py: db=DAL(uri, migrate=True) current.db = db And in modules/MyClass.py: from gluon import current class MyClass(object): def __init__(self): self.db = current.db But i still

Re: [web2py] Access db in module

2013-07-05 Thread Michele Comitini
You can try db = current.globalenv['db'] but you can do simply def __init__(self, db): self.db = db and instantiate MyClass in your controller or model as: myobj = MyClass(db) mic 2013/7/5 Remco K remc...@gmail.com Hi all, I have a class in modules from which i can't access the DB