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 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 can't access the db object from within my class.
The error i get is:
AttributeError: 'thread._local' object has no attribute 'db'
Can someone tell me how to use this in the right way?
Thanks in advance!
Remco
--
---
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
---
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.