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

Merged
merged 1 commit into from Oct 19, 2015

Conversation

Projects
None yet
9 participants
@hbldh
Contributor

hbldh commented Jul 2, 2015

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:

  • 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 and both have to be overridden.
  • 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 and update methods, 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.
@markunsworth

This comment has been minimized.

Show comment
Hide comment
@markunsworth

markunsworth Jul 14, 2015

Contributor

Nice one.

Removing the MongoReplicaSetClient would mean this is not backwards compatible with pymongo 2.x - is this desirable?

Contributor

markunsworth commented Jul 14, 2015

Nice one.

Removing the MongoReplicaSetClient would mean this is not backwards compatible with pymongo 2.x - is this desirable?

This was referenced Jul 14, 2015

@nicolaiarocci

This comment has been minimized.

Show comment
Hide comment
@nicolaiarocci

nicolaiarocci commented Jul 14, 2015

👍

@hbldh

This comment has been minimized.

Show comment
Hide comment
@hbldh

hbldh Jul 14, 2015

Contributor

@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 __init__.py, lines 232 to 240 to see that an explicit check is done for pymongo < 3.x and then, if found True, using the pre-existing code for selecting the connection class.

Contributor

hbldh commented Jul 14, 2015

@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 __init__.py, lines 232 to 240 to see that an explicit check is done for pymongo < 3.x and then, if found True, using the pre-existing code for selecting the connection class.

@markunsworth

This comment has been minimized.

Show comment
Hide comment
@markunsworth

markunsworth Jul 15, 2015

Contributor

Sorry I didn't actually read the commit message properly.

I'm all for this being merged as is then

Contributor

markunsworth commented Jul 15, 2015

Sorry I didn't actually read the commit message properly.

I'm all for this being merged as is then

@jbouzekri

This comment has been minimized.

Show comment
Hide comment
@jbouzekri

jbouzekri Jul 18, 2015

Contributor

+1

Contributor

jbouzekri commented Jul 18, 2015

+1

@phaethon

This comment has been minimized.

Show comment
Hide comment
@phaethon

phaethon commented Jul 22, 2015

+1

@drankinn

This comment has been minimized.

Show comment
Hide comment
@drankinn

drankinn commented Jul 24, 2015

+1

@ranman

This comment has been minimized.

Show comment
Hide comment
@ranman

ranman Aug 7, 2015

Contributor

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.

Contributor

ranman commented Aug 7, 2015

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.

@hbldh

This comment has been minimized.

Show comment
Hide comment
@hbldh

hbldh Aug 7, 2015

Contributor

@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...

Contributor

hbldh commented Aug 7, 2015

@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...

@ColeKettler

This comment has been minimized.

Show comment
Hide comment
@ColeKettler

ColeKettler Sep 9, 2015

Big +1 on this. Is this still mergeable?

ColeKettler commented Sep 9, 2015

Big +1 on this. Is this still mergeable?

Modifications to enable pymongo 3.0.x compatability.
* 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.
@lucidfrontier45

This comment has been minimized.

Show comment
Hide comment
@lucidfrontier45

lucidfrontier45 Oct 19, 2015

+1

I think 3.0 compatibility is very important feature and I'm waiting for this PR to be merged.
What is current status?

lucidfrontier45 commented Oct 19, 2015

+1

I think 3.0 compatibility is very important feature and I'm waiting for this PR to be merged.
What is current status?

ranman added a commit that referenced this pull request Oct 19, 2015

Merge pull request #63 from hbldh/pymongo3.0_feature
Modifications to enable pymongo 3.0.x compatability.

@ranman ranman merged commit a21fda7 into dcrosta:master Oct 19, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment