forked from orbit-oss/flask
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
|
.. autoclass:: Request
|
||||||
:members:
|
:members:
|
||||||
:inherited-members:
|
:inherited-members:
|
||||||
:exclude-members: json_module
|
:exclude-members: json_module
|
||||||
|
|
||||||
.. attribute:: request
|
.. attribute:: request
|
||||||
|
|
||||||
|
|
@ -48,20 +48,9 @@ Response Objects
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. autoclass:: flask.Response
|
.. autoclass:: flask.Response
|
||||||
:members: set_cookie, max_cookie_size, data, mimetype, is_json, get_json
|
:members:
|
||||||
|
:inherited-members:
|
||||||
.. attribute:: headers
|
:exclude-members: json_module
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
Sessions
|
Sessions
|
||||||
--------
|
--------
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,12 @@
|
||||||
from werkzeug.exceptions import BadRequest
|
from werkzeug.exceptions import BadRequest
|
||||||
from werkzeug.wrappers import Request as RequestBase
|
from werkzeug.wrappers import Request as RequestBase
|
||||||
from werkzeug.wrappers import Response as ResponseBase
|
from werkzeug.wrappers import Response as ResponseBase
|
||||||
from werkzeug.wrappers.json import JSONMixin as _JSONMixin
|
|
||||||
|
|
||||||
from . import json
|
from . import json
|
||||||
from .globals import current_app
|
from .globals import current_app
|
||||||
|
|
||||||
|
|
||||||
class JSONMixin(_JSONMixin):
|
class Request(RequestBase):
|
||||||
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):
|
|
||||||
"""The request object used by default in Flask. Remembers the
|
"""The request object used by default in Flask. Remembers the
|
||||||
matched endpoint and view arguments.
|
matched endpoint and view arguments.
|
||||||
|
|
||||||
|
|
@ -30,6 +19,8 @@ class Request(RequestBase, JSONMixin):
|
||||||
specific ones.
|
specific ones.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
json_module = json
|
||||||
|
|
||||||
#: The internal URL rule that matched the request. This can be
|
#: The internal URL rule that matched the request. This can be
|
||||||
#: useful to inspect which methods are allowed for the URL from
|
#: useful to inspect which methods are allowed for the URL from
|
||||||
#: a before/after handler (``request.url_rule.methods``) etc.
|
#: a before/after handler (``request.url_rule.methods``) etc.
|
||||||
|
|
@ -89,8 +80,14 @@ class Request(RequestBase, JSONMixin):
|
||||||
|
|
||||||
attach_enctype_error_multidict(self)
|
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
|
"""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
|
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
|
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"
|
default_mimetype = "text/html"
|
||||||
|
|
||||||
def _get_data_for_json(self, cache):
|
json_module = json
|
||||||
return self.get_data()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_cookie_size(self):
|
def max_cookie_size(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue