Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Modifications to enable pymongo 3.0.x compatability. #63
This pull request is an attempt of enabling the use of pymongo >= 3.0.
@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.
@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...
* 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.