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
Provenance
- Commit
8661183- Tree
181d5a2- Author
Adam Byrtek <adambyrtek@gmail.com>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent
5ebdd5d
1 file changed+16 added−15 removed
modified:flask/wrappers.py+16 added-15 removed
13 unmodified lines14 15 from . import json16 from .globals import _app_ctx_stack17 18-_missing = object()18 20-19 class 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.22 23 .. versionadded:: 0.1224 """25 26 @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`.31+32+ .. versionadded:: 1.033 """34 mt = self.mimetype35 if mt == 'application/json':36 return True2 unmodified lines39 return False40 41 @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``.45 46 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()52 53 def _get_data_for_json(self, cache):54 getter = getattr(self, 'get_data', None)12 unmodified lines67 :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+ pass77 78 if not (force or self.is_json):79 return None80 80- # 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