我正在尝试创建一个脚本,该脚本将利用 web2py DAL 访问远程数据库。我希望该应用程序能够访问另一个 web2py 应用程序的身份验证表。脚本如下:
if MODE == 'server':
DIR_GLUON = '...'
else:
DIR_GLUON = '...'
sys_path.insert(0, DIR_GLUON)
from gluon import DAL, Field, current
from gluon.tools import Auth
from gluon.storage import Storage
import gluon.contrib.plural_rules as plural_rules
# establish DB connection
db = DAL(..., pool_size = 1, check_reserved=['all'], lazy_tables = True, fake_migrate_all = True)
auth = Auth(db)
最后一行产生以下错误:
Traceback (most recent call last):
File "standalone_script.py", line 39, in <module>
auth = Auth(db)
File "C:\...\web2py\gluon\tools.py", line 1754, in __init__
request = current.request
AttributeError: 'thread._local' object has no attribute 'request'
有没有一种合理的方法可以在独立环境中解决上述错误?谢谢你。