|
33 | 33 | from flask.json.provider import JSONProvider |
34 | 34 | from werkzeug.routing import BaseConverter |
35 | 35 | 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 |
42 | 37 |
|
43 | 38 |
|
44 | 39 | def _iteritems(obj): |
@@ -101,32 +96,14 @@ def json_route(cart_id): |
101 | 96 | differently than you expect. See :class:`~bson.json_util.JSONOptions` |
102 | 97 | for details on the particular serialization that will be used. |
103 | 98 |
|
104 | | - A :class:`~flask_pymongo.helpers.JSONEncoder` is automatically |
| 99 | + A :class:`~flask_pymongo.helpers.JSONProvider` is automatically |
105 | 100 | automatically installed on the :class:`~flask_pymongo.PyMongo` |
106 | 101 | 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`. |
121 | 103 | """ |
122 | 104 |
|
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} |
130 | 107 |
|
131 | 108 | super().__init__(app) |
132 | 109 |
|
|
0 commit comments