Skip to content

Commit a44bb38

Browse files
committed
fix handling of json_options
1 parent 0df9706 commit a44bb38

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

flask_pymongo/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ class PyMongo(object):
6666
6767
"""
6868

69-
def __init__(self, app=None, uri=None, json_options=None, *args, **kwargs):
69+
def __init__(self, app=None, uri=None, *args, **kwargs):
7070
self.cx = None
7171
self.db = None
72-
self._json_provider = BSONProvider(json_options, app)
72+
self._json_provider = BSONProvider(app)
7373

7474
if app is not None:
7575
self.init_app(app, uri, *args, **kwargs)

flask_pymongo/helpers.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@
3333
from flask.json.provider import JSONProvider
3434
from werkzeug.routing import BaseConverter
3535
import pymongo
36-
37-
if pymongo.version_tuple >= (3, 5, 0):
38-
from bson.json_util import RELAXED_JSON_OPTIONS
39-
DEFAULT_JSON_OPTIONS = RELAXED_JSON_OPTIONS
40-
else:
41-
DEFAULT_JSON_OPTIONS = None
36+
from bson.json_util import RELAXED_JSON_OPTIONS
4237

4338

4439
def _iteritems(obj):
@@ -101,32 +96,14 @@ def json_route(cart_id):
10196
differently than you expect. See :class:`~bson.json_util.JSONOptions`
10297
for details on the particular serialization that will be used.
10398
104-
A :class:`~flask_pymongo.helpers.JSONEncoder` is automatically
99+
A :class:`~flask_pymongo.helpers.JSONProvider` is automatically
105100
automatically installed on the :class:`~flask_pymongo.PyMongo`
106101
instance at creation time, using
107-
:const:`~bson.json_util.RELAXED_JSON_OPTIONS`. You can change the
108-
:class:`~bson.json_util.JSONOptions` in use by passing
109-
``json_options`` to the :class:`~flask_pymongo.PyMongo`
110-
constructor.
111-
112-
.. note::
113-
114-
:class:`~bson.json_util.JSONOptions` is only supported as of
115-
PyMongo version 3.4. For older versions of PyMongo, you will
116-
have less control over the JSON format that results from calls
117-
to :func:`~flask.json.jsonify`.
118-
119-
.. versionadded:: 2.4.0
120-
102+
:const:`~bson.json_util.RELAXED_JSON_OPTIONS`.
121103
"""
122104

123-
def __init__(self, json_options, app):
124-
if json_options is None:
125-
json_options = DEFAULT_JSON_OPTIONS
126-
if json_options is not None:
127-
self._default_kwargs = {"json_options": json_options}
128-
else:
129-
self._default_kwargs = {}
105+
def __init__(self, app):
106+
self._default_kwargs = {"json_options": RELAXED_JSON_OPTIONS}
130107

131108
super().__init__(app)
132109

0 commit comments

Comments
 (0)