Skip to content
Myr

Added the JSONIFY_PRETTYPRINT_REGULAR config variable. This fixes #725

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 1c8c21a · Browse files · 4 files+18 added−3 removed
This commit

State

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

Diff stats

4 files+18 added−3 removed

  • other:+18 added−3 removed

4 files+18 added−3 removed

modified:docs/config.rst+6 added-1 removed
147 unmodified lines
148 and output strings as-is and return149 unicode strings. ``jsonfiy`` will150 automatically encode it in ``utf-8``151 then for transport for instance.152``JSONIFY_PRETTYPRINT_REGULAR`` If this is set to ``True`` (the default)153 jsonify responses will be pretty printed154 if they are not requested by an155 XMLHttpRequest object (controlled by156 the ``X-Requested-With`` header)157================================= =========================================158159.. admonition:: More on ``SERVER_NAME``160
35 unmodified lines
196.. versionadded:: 0.9197 ``PREFERRED_URL_SCHEME``198199.. versionadded:: 0.10195 ``JSON_AS_ASCII``200 ``JSON_AS_ASCII``, ``JSONIFY_PRETTYPRINT_REGULAR``201202Configuring from Files203----------------------204
214 unmodified lines
modified:flask/app.py+2 added-1 removed
288 unmodified lines
289 'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours290 'TRAP_BAD_REQUEST_ERRORS': False,291 'TRAP_HTTP_EXCEPTIONS': False,292 'PREFERRED_URL_SCHEME': 'http',293 'JSON_AS_ASCII': True293 'JSON_AS_ASCII': True,294 'JSONIFY_PRETTYPRINT_REGULAR': True,295 })296297 #: The rule object to use for URL rules created. This is used by298 #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`.
1536 unmodified lines
modified:flask/json.py+9 added-1 removed
192 unmodified lines
193194 For security reasons only objects are supported toplevel. For more195 information about this, have a look at :ref:`json-security`.196197 This function's response will be pretty printed if it was not requested198 with ``X-Requested-With: XMLHttpRequest`` to simplify debugging unless199 the ``JSONIFY_PRETTYPRINT_REGULAR`` config parameter is set to false.200201 .. versionadded:: 0.2202 """203 indent = None204 if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \205 and not request.is_xhr:206 indent = 2207 return current_app.response_class(dumps(dict(*args, **kwargs),200 indent=None if request.is_xhr else 2),208 indent=indent),209 mimetype='application/json')
modified:CHANGES+1 added
60 unmodified lines
61 for Python 3.3 port.62- Changed how the teardown system is informed about exceptions. This is now63 more reliable in case something handles an exception halfway through64 the error handling process.65- Added the ``JSONIFY_PRETTYPRINT_REGULAR`` configuration variable.6667Version 0.968-----------69
365 unmodified lines