pyMongo 4.0.1 deprecated methods
DRN88 opened this issue · comments
Expected Behavior
Authentication and Eve working as normal.
Actual Behavior
Authentication (and other things) fail due to deprecated functions in /eve/io/mongo/flask_pymongo.py
(and maybe in more files?)
pyMongo defaults to 4.0.1 version.
https://github.com/pyeve/eve/blob/master/eve/io/mongo/flask_pymongo.py#L97
root@mongodb1:/opt/eve# pip3 install pyMongo==4.0.1
Collecting pyMongo==4.0.1
Using cached pymongo-4.0.1-cp38-cp38-manylinux2014_x86_64.whl (486 kB)
Installing collected packages: pyMongo
Attempting uninstall: pyMongo
Found existing installation: pymongo 3.12.3
Uninstalling pymongo-3.12.3:
Successfully uninstalled pymongo-3.12.3
Successfully installed pyMongo-4.0.1
root@mongodb1:/opt/eve# pip3 install pyMongo==
ERROR: Could not find a version that satisfies the requirement pyMongo== (from versions: 0.1rc0, 0.1.1rc0, 0.1.2rc0, 0.2rc0, 0.3rc0, 0.3.1rc0, 0.4rc0, 0.5rc0, 0.5.1rc0, 0.5.2rc0, 0.5.3rc0, 0.6, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.9, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7, 0.10, 0.10.1, 0.10.2, 0.10.3, 0.11, 0.11.1, 0.11.2, 0.11.3, 0.12, 0.13, 0.14, 0.14.1, 0.14.2, 0.15, 0.15.1, 0.15.2, 0.16, 1.0, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.3, 1.4, 1.5, 1.5.1, 1.5.2, 1.6, 1.7, 1.8, 1.8.1, 1.9, 1.10, 1.10.1, 1.11, 2.0, 2.0.1, 2.1, 2.1.1, 2.2, 2.2.1, 2.3, 2.4, 2.4.1, 2.4.2, 2.5, 2.5.1, 2.5.2, 2.6, 2.6.1, 2.6.2, 2.6.3, 2.7, 2.7.1, 2.7.2, 2.8, 2.8.1, 2.9, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 2.9.5, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.1, 3.1.1, 3.2, 3.2.1, 3.2.2, 3.3.0, 3.3.1, 3.4.0, 3.5.0, 3.5.1, 3.6.0, 3.6.1, 3.7.0, 3.7.1, 3.7.2, 3.8.0, 3.9.0, 3.10.0, 3.10.1, 3.11.0, 3.11.1, 3.11.2, 3.11.3, 3.11.4, 3.12.0, 3.12.1, 3.12.2, 3.12.3, 4.0, 4.0.1)
ERROR: No matching distribution found for pyMongo==
root@mongodb1:/opt/eve#
root@mongodb1:/opt/eve# python3 main.py
* Serving Flask app 'eve' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://192.168.123.174:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 137-497-020
192.168.199.2 - - [24/Jan/2022 10:20:23] "GET /Orders HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/eve/flaskapp.py", line 1110, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/usr/local/lib/python3.8/dist-packages/eve/endpoints.py", line 56, in collections_endpoint
response = get(resource, lookup)
File "/usr/local/lib/python3.8/dist-packages/eve/methods/common.py", line 325, in rate_limited
return f(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/eve/auth.py", line 80, in decorated
return f(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/eve/methods/common.py", line 1373, in decorated
r = f(resource, **combined_args)
File "/usr/local/lib/python3.8/dist-packages/eve/methods/get.py", line 51, in get
return get_internal(resource, **lookup)
File "/usr/local/lib/python3.8/dist-packages/eve/methods/get.py", line 125, in get_internal
return _perform_find(resource, lookup)
File "/usr/local/lib/python3.8/dist-packages/eve/methods/get.py", line 264, in _perform_find
cursor, count = app.data.find(
File "/usr/local/lib/python3.8/dist-packages/eve/io/mongo/mongo.py", line 262, in find
target = self.pymongo(resource).db[datasource]
File "/usr/local/lib/python3.8/dist-packages/eve/io/mongo/mongo.py", line 1062, in pymongo
self.driver[px] = PyMongo(self.app, px)
File "/usr/local/lib/python3.8/dist-packages/eve/io/mongo/flask_pymongo.py", line 97, in __init__
db.authenticate(username, password, **auth_kwargs)
File "/usr/local/lib/python3.8/dist-packages/pymongo/collection.py", line 2579, in __call__
raise TypeError("'Collection' object is not callable. If you "
TypeError: 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
192.168.199.2 - - [24/Jan/2022 10:20:24] "GET /Orders?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
192.168.199.2 - - [24/Jan/2022 10:20:24] "GET /Orders?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
192.168.199.2 - - [24/Jan/2022 10:20:24] "GET /Orders?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
192.168.199.2 - - [24/Jan/2022 10:20:24] "GET /Orders?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
root@mongodb1:/opt/eve# pip3 install pyMongo==3.12.3
Collecting pyMongo==3.12.3
Using cached pymongo-3.12.3-cp38-cp38-manylinux2014_x86_64.whl (546 kB)
Installing collected packages: pyMongo
Attempting uninstall: pyMongo
Found existing installation: pymongo 4.0.1
Uninstalling pymongo-4.0.1:
Successfully uninstalled pymongo-4.0.1
Successfully installed pyMongo-3.12.3
root@mongodb1:/opt/eve#
root@mongodb1:/opt/eve# python3 main.py
* Serving Flask app 'eve' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://192.168.123.174:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 137-497-020
192.168.199.2 - - [24/Jan/2022 10:21:25] "GET /Orders HTTP/1.1" 200 -
Environment
- Python version: Python 3.8.10
- Eve version: 1.1.5
Workaround
Use older version of pyMongo. :(
pip3 install pyMongo==3.12.3
duplicate of #1461
PS: PyMongo 4 drops support for Python 2. We first have to drop py2 too.
Support for pymongo 4+ is now available on master branch. Would be nice if you folks could test it a little bit.