我正在使用Eve制作REST API。 Eve在Docker容器上运行Nginx和uwsgi。
Python版:3.6.5
夏娃:0.8
Eve-SQLAlchemy :0.5.0
当我发送资源和项目的GET请求时,没有问题。 但是,当我发送PATCH或DELETE请求时,API服务器返回Nginx的默认50xError页面。
日志是这样的:
[pid: 12|app: 0|req: 22/22] 192.168.99.1 () {46 vars in 691 bytes} [Wed Jun 6 22:55:26 2018] PATCH /maintenances/18 => generated 0 bytes in 11 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/eve/flaskapp.py", line 1043, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib64/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/python3.6/site-packages/eve/endpoints.py", line 96, in item_endpoint
response = patch(resource, **lookup)
File "/usr/lib/python3.6/site-packages/eve/methods/common.py", line 297, in rate_limited
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/eve/auth.py", line 78, in decorated
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/eve/methods/common.py", line 1181, in decorated
r = f(resource, **combined_args)
File "/usr/lib/python3.6/site-packages/eve/methods/patch.py", line 41, in patch
skip_validation=False, **lookup)
File "/usr/lib/python3.6/site-packages/eve/methods/patch.py", line 134, in patch_internal
original = get_document(resource, concurrency_check, **lookup)
File "/usr/lib/python3.6/site-packages/eve/methods/common.py", line 80, in get_document
**lookup)
TypeError: find_one() takes 3 positional arguments but 5 were given
当我从请求中删除身份验证时,服务器返回"请提供正确的凭据,"但是当我删除" If-Match"来自请求的标头,服务器返回此错误。 (因此,认证和etag验证之间存在的某些过程可能是导致此错误的原因。
答案 0 :(得分:0)
它几乎肯定与Eve和Eve-SQLAlchemy之间的版本不兼容有关。 Eve-SQLAlchemy 0.5仅支持Eve 0.6 ,目前还没有支持更新Eve版本的版本。
这也与您看到的TypeError
匹配:find_one()
是数据层中的一种方法,Eve-SQLAlchemy提供了该方法。可能在Eve 0.7或0.8中界面发生了变化。
如果您正在使用pip,则pip check
应报告您的安装错误,因为Eve-SQLAlchemy声明它取决于Eve>=0.6,<0.7
(请参阅https://github.com/pyeve/eve-sqlalchemy/blob/586cec403daabaeab8f7cbe133275d5fcc4e4bf3/setup.py#L35)。
要解决此问题,请在您的setup.py
和/或requirements.txt
中移除任何不相关的Eve版本,或者如果这不会改变任何内容,请添加Eve<0.7
。不幸的是,pip并不总能为所有依赖项本身确定一组非矛盾的版本,因此有时需要指导。