Skip to content
Myr

clean up

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

authored by David Lord · committed by David Lord · parent 7df543d · Browse files · 1 file+6 added−11 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+6 added−11 removed

  • other:+6 added−11 removed

1 file+6 added−11 removed

modified:flask/json.py+6 added-11 removed
193 unmodified lines
194195196def htmlsafe_dump(obj, fp, **kwargs):197 """Like :func:`htmlsafe_dumps` but writes into a file object."""198 fp.write(unicode(htmlsafe_dumps(obj, **kwargs)))198 fp.write(text_type(htmlsafe_dumps(obj, **kwargs)))199200201def jsonify(*args, **kwargs):202 """This function wraps :func:`dumps` to add a few enhancements that make
47 unmodified lines
250251 indent = None252 separators = (',', ':')253254 if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \255 and not request.is_xhr:254 if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:255 indent = 2256 separators = (', ', ': ')257258 if args and kwargs:260 raise TypeError(261 "jsonify() behavior undefined when passed both args and kwargs"262 )259 raise TypeError('jsonify() behavior undefined when passed both args and kwargs')260 elif len(args) == 1: # single args are passed directly to dumps()261 data = args[0]262 else:263 data = args or kwargs264268 # Note that we add '\n' to end of response269 # (see https://github.com/mitsuhiko/flask/pull/1262)270 rv = current_app.response_class(265 return current_app.response_class(266 (dumps(data, indent=indent, separators=separators), '\n'),272 mimetype='application/json')273 return rv267 mimetype='application/json'268 )269270271def tojson_filter(obj, **kwargs):272 return Markup(htmlsafe_dumps(obj, **kwargs))