remove JSONMixin
This commit is contained in:
parent
d887d32f4d
commit
fdba0d2526
2 changed files with 17 additions and 32 deletions
23
docs/api.rst
23
docs/api.rst
|
|
@ -27,9 +27,9 @@ Incoming Request Data
|
|||
---------------------
|
||||
|
||||
.. autoclass:: Request
|
||||
:members:
|
||||
:inherited-members:
|
||||
:exclude-members: json_module
|
||||
:members:
|
||||
:inherited-members:
|
||||
:exclude-members: json_module
|
||||
|
||||
.. attribute:: request
|
||||
|
||||
|
|
@ -48,20 +48,9 @@ Response Objects
|
|||
----------------
|
||||
|
||||
.. autoclass:: flask.Response
|
||||
:members: set_cookie, max_cookie_size, data, mimetype, is_json, get_json
|
||||
|
||||
.. attribute:: headers
|
||||
|
||||
A :class:`~werkzeug.datastructures.Headers` object representing the response headers.
|
||||
|
||||
.. attribute:: status
|
||||
|
||||
A string with a response status.
|
||||
|
||||
.. attribute:: status_code
|
||||
|
||||
The response status as integer.
|
||||
|
||||
:members:
|
||||
:inherited-members:
|
||||
:exclude-members: json_module
|
||||
|
||||
Sessions
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -1,23 +1,12 @@
|
|||
from werkzeug.exceptions import BadRequest
|
||||
from werkzeug.wrappers import Request as RequestBase
|
||||
from werkzeug.wrappers import Response as ResponseBase
|
||||
from werkzeug.wrappers.json import JSONMixin as _JSONMixin
|
||||
|
||||
from . import json
|
||||
from .globals import current_app
|
||||
|
||||
|
||||
class JSONMixin(_JSONMixin):
|
||||
json_module = json
|
||||
|
||||
def on_json_loading_failed(self, e):
|
||||
if current_app and current_app.debug:
|
||||
raise BadRequest(f"Failed to decode JSON object: {e}")
|
||||
|
||||
raise BadRequest()
|
||||
|
||||
|
||||
class Request(RequestBase, JSONMixin):
|
||||
class Request(RequestBase):
|
||||
"""The request object used by default in Flask. Remembers the
|
||||
matched endpoint and view arguments.
|
||||
|
||||
|
|
@ -30,6 +19,8 @@ class Request(RequestBase, JSONMixin):
|
|||
specific ones.
|
||||
"""
|
||||
|
||||
json_module = json
|
||||
|
||||
#: The internal URL rule that matched the request. This can be
|
||||
#: useful to inspect which methods are allowed for the URL from
|
||||
#: a before/after handler (``request.url_rule.methods``) etc.
|
||||
|
|
@ -89,8 +80,14 @@ class Request(RequestBase, JSONMixin):
|
|||
|
||||
attach_enctype_error_multidict(self)
|
||||
|
||||
def on_json_loading_failed(self, e):
|
||||
if current_app and current_app.debug:
|
||||
raise BadRequest(f"Failed to decode JSON object: {e}")
|
||||
|
||||
class Response(JSONMixin, ResponseBase):
|
||||
raise BadRequest()
|
||||
|
||||
|
||||
class Response(ResponseBase):
|
||||
"""The response object that is used by default in Flask. Works like the
|
||||
response object from Werkzeug but is set to have an HTML mimetype by
|
||||
default. Quite often you don't have to create this object yourself because
|
||||
|
|
@ -110,8 +107,7 @@ class Response(JSONMixin, ResponseBase):
|
|||
|
||||
default_mimetype = "text/html"
|
||||
|
||||
def _get_data_for_json(self, cache):
|
||||
return self.get_data()
|
||||
json_module = json
|
||||
|
||||
@property
|
||||
def max_cookie_size(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue