Skip to content

Pymongo support < 3.6.0 dropped #372

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

Merged
merged 2 commits into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ Thomas Steinacher
Anthony Nemitz
Nauman Ahmad

CURRENT MAINTAINER:

Andrey Shpak - https://github.com/insspb

CONTRIBUTORS

Dervived from the git logs, inevitably incomplete but all of whom and others
have submitted patches, reported bugs and generally helped make MongoEngine
that much better:

* Insspb - https://github.com/insspb
* Tony Narlock - https://github.com/tony
* Dragos - https://github.com/cdragos
* IamFive - https://github.com/IamFive
* mickey06 - https://github.com/mickey06
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Development
- BREAKING CHANGE: Minimum Flask-WTF version set to v0.14 (#355)
- BREAKING CHANGE: Minimum mongoengine version set to v0.19 (#355)
- BREAKING CHANGE: Minimum mongodb version set to v4.0 (#355)
- BREAKING CHANGE: Pymongo support < 3.6.0 dropped. (#372)
- FIXED: Pymongo old method monkey patching (#325, #346, #372)
- FIXED: Examples works again (#372)
- CHANGED: Code reformatted with black, pre-commit implemented
in project and CI/CD (#366)
- CHANGED: Developers dependencies extracted to separate file (#367)
Expand Down
15 changes: 8 additions & 7 deletions flask_mongoengine/operation_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pymongo.collection
import pymongo.cursor
import pymongo.helpers

import pymongo.command_cursor

__all__ = [
"queries",
Expand All @@ -32,7 +32,7 @@
"update": pymongo.collection.Collection.update,
"remove": pymongo.collection.Collection.remove,
"refresh": pymongo.cursor.Cursor._refresh,
"_unpack_response": pymongo.helpers._unpack_response,
"_unpack_response": pymongo.command_cursor.CommandCursor._unpack_response,
}

queries = []
Expand All @@ -48,7 +48,6 @@
# Wrap helpers._unpack_response for getting response size
@functools.wraps(_original_methods["_unpack_response"])
def _unpack_response(response, *args, **kwargs):

result = _original_methods["_unpack_response"](response, *args, **kwargs)
response_sizes.append(sys.getsizeof(response, len(response)) / 1024.0)
return result
Expand Down Expand Up @@ -226,8 +225,8 @@ def install_tracker():
pymongo.collection.Collection.remove = _remove
if pymongo.cursor.Cursor._refresh != _cursor_refresh:
pymongo.cursor.Cursor._refresh = _cursor_refresh
if pymongo.helpers._unpack_response != _unpack_response:
pymongo.helpers._unpack_response = _unpack_response
if pymongo.command_cursor.CommandCursor._unpack_response != _unpack_response:
pymongo.command_cursor.CommandCursor._unpack_response = _unpack_response


def uninstall_tracker():
Expand All @@ -239,8 +238,10 @@ def uninstall_tracker():
pymongo.collection.Collection.remove = _original_methods["remove"]
if pymongo.cursor.Cursor._refresh == _cursor_refresh:
pymongo.cursor.Cursor._refresh = _original_methods["cursor_refresh"]
if pymongo.helpers._unpack_response == _unpack_response:
pymongo.helpers._unpack_response = _original_methods["_unpack_response"]
if pymongo.command_cursor.CommandCursor._unpack_response == _unpack_response:
pymongo.command_cursor.CommandCursor._unpack_response = _original_methods[
"_unpack_response"
]


def reset():
Expand Down