-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifications to enable pymongo 3.0.x compatability. #63
Conversation
Nice one. Removing the MongoReplicaSetClient would mean this is not backwards compatible with pymongo 2.x - is this desirable? |
👍 |
@markunsworth The MongoReplicaSetClient is not removed in the pymongo < 3.0 case. It is still the preferred way of connecting to a Replica Set in that case and should definitely be used. Check |
Sorry I didn't actually read the commit message properly. I'm all for this being merged as is then |
+1 |
2 similar comments
+1 |
+1 |
Hey this looks good and I'm all set to merge it after some more testing. Mind giving it one more once over to make sure there's nothing you want to change since it's been a while. |
@ranman Did as you suggested, gave it a once over and saw some minor mistakes I made, mainly PEP8 violations. Sadly the Travis build for Python 3.4 failed and it seems to be due to that the MongoClient took longer time than 0.01 seconds to establish connection to the database and set its address properties. It should work, either by just running it again or increasing the sleep duration. Neither suggestion is especially compelling... |
Big +1 on this. Is this still mergeable? |
* Removed `auto_start_request` from __init__ in the pymongo >= 3.0 case. * Using only the MongoClient for pymongo >= 3.0 case, since MongoReplicaSetClient is labelled deprecated and all functionality has been merged to MongoClient. * Wrappers has a overriding `__getitem__` method added. In pymongo < 3.0 the `__getitem__` method (used when calling c[db_name]) called the `__getattr__` method (used when calling c.db_name), so wrappers did not need to override both then. In pymongo > 3.0 this is not the case. * Tests in test_config.py use `mongo.cx.address` property instead of `host` and `port` properties of the MongoClient in the pymongo >= 3.0 case, since they have been removed. All tests using this property also sleeps a short time since the client needs some time to establish connection to MongoDB and set the proper values, otherwise the tests fails. * The `safe` keyword is deprecated for insert method, though only flagged in pymongo 2.x. Change all these to `w=1` which has equal effect. `insert` method also has a deprecation warning in pymongo 3.0.x, so `insert_one` is used instead in these cases.
+1 I think 3.0 compatibility is very important feature and I'm waiting for this PR to be merged. |
Modifications to enable pymongo 3.0.x compatability.
This pull request is an attempt of enabling the use of pymongo >= 3.0.
In
__init__.py
and the test files there are explicit tests whether pymongo >= 3.0 is used, which is ugly, but I have deemed it necessary to bridge the deprecation problems.Modifications:
auto_start_request
from init in the pymongo >= 3.0 case.MongoClient
for pymongo >= 3.0 case, sinceMongoReplicaSetClient
is labelled deprecated and all functionality has been merged toMongoClient
.__getitem__
method added. In pymongo < 3.0 the__getitem__
method (used when callingc[db_name]
) called the__getattr__
method (used when callingc.db_name
), so wrappers did not need to override both then. In pymongo > 3.0 this is not the case and both have to be overridden.test_config.py
usemongo.cx.address
property instead ofhost
andport
properties of theMongoClient
in the pymongo >= 3.0 case, since they have been removed. All tests using this property also sleeps a short time since the client needs some time to establish connection to MongoDB and set the proper values, otherwise the tests fails.safe
keyword is deprecated forinsert
andupdate
methods, though only flagged in pymongo 2.x. Change all these tow=1
which has equal effect.insert
method also has a deprecation warning in pymongo 3.0.x, soinsert_one
is used instead in these cases.