【发布时间】:2017-03-14 13:15:58
【问题描述】:
在我的 setting.py 中,我声明了自定义身份验证类
from flask import current_app as app
class MyAuth(BasicAuth):
def check_auth(self, username, password, allowed_roles, resource, method):
users = app.data.driver.db['users']
... some logic here...
我在我的一个域中使用它:
my_clients = {
'schema' :clientsSchema,
'authentication': MyAuth
}
我收到以下错误:
File " ... eve/settings.py", line 24, in check_auth
users = app.data.driver.db['users']
AttributeError: 'NoneType' object has no attribute 'data'
当 MyAuth 类在 settings.py 中声明时,有什么方法可以从 MyAuth 类访问 Eve db 连接对象并像在 the tutorial 中一样使用它?
【问题讨论】:
-
您的应用程序运行情况如何?我有一个类似的设置工作。
-
我用
python run.py运行它,其中run.py 是app = Eve() if __name__ == '__main__': app.run(host='0.0.0.0',port=80)
标签: python rest api authentication eve