Skip to content
Myr

Remove _missing sentinel and update docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Adam Byrtek · committed by Markus Unterwaditzer · parent 5ebdd5d · Browse files · 1 file+16 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−15 removed

  • other:+16 added−15 removed

1 file+16 added−15 removed

modified:flask/wrappers.py+16 added-15 removed
13 unmodified lines
1415from . import json16from .globals import _app_ctx_stack1718_missing = object()182019class JSONMixin(object):22 """Mixin for both request and response classes to provide JSON parsing23 capabilities.20 """Common mixin for both request and response objects to provide JSON21 parsing capabilities.2223 .. versionadded:: 0.1224 """2526 @property27 def is_json(self):30 """Indicates if this request/response is JSON or not. By default it31 is considered to include JSON data if the mimetype is28 """Indicates if this request/response is in JSON format or not. By29 default it is considered to include JSON data if the mimetype is30 :mimetype:`application/json` or :mimetype:`application/*+json`.3132 .. versionadded:: 1.033 """34 mt = self.mimetype35 if mt == 'application/json':36 return True
2 unmodified lines
39 return False4041 @property42 def json(self):43 """If the mimetype is :mimetype:`application/json` this will contain the44 parsed JSON data. Otherwise this will be ``None``.43 """If this request/response is in JSON format then this property will44 contain the parsed JSON data. Otherwise it will be ``None``.4546 The :meth:`get_json` method should be used instead.47 """48 from warnings import warn49 warn(DeprecationWarning('json is deprecated. '50 'Use get_json() instead.'), stacklevel=2)49 warn(DeprecationWarning(50 'json is deprecated. Use get_json() instead.'), stacklevel=2)51 return self.get_json()5253 def _get_data_for_json(self, cache):54 getter = getattr(self, 'get_data', None)
12 unmodified lines
67 :param force: if set to ``True`` the mimetype is ignored.68 :param silent: if set to ``True`` this method will fail silently69 and return ``None``.70 :param cache: if set to ``True`` the parsed JSON data is remembered71 on the request.71 on the object.72 """73 rv = getattr(self, '_cached_json', _missing)74 if rv is not _missing:75 return rv73 try:74 return getattr(self, '_cached_json')75 except AttributeError:76 pass7778 if not (force or self.is_json):79 return None8080 # We accept a request charset against the specification as certain81 # We accept MIME charset header against the specification as certain82 # clients have been using this in the past. For responses, we assume83 # that if the response charset was set explicitly then the data had84 # been encoded correctly as well.85 charset = self.mimetype_params.get('charset')
132 unmodified lines