Permalink
Browse files

Reverted changes made by too-eager merge with pull request #502.

  • Loading branch information...
1 parent 08f3af6 commit 1e2aae294d9bf57b31a3e39cb97084f47a41e6a0 @jfinkels committed May 2, 2012
Showing with 14 additions and 15 deletions.
  1. +0 −2 CHANGES
  2. +14 −13 flask/helpers.py
View
@@ -10,8 +10,6 @@ Relase date to be decided, codename to be chosen.
- Added :attr:`flask.Flask.json_encoder_class` so users can customize JSON
encoding during execution of the :func:`flask.jsonify` function.
-- The :func:`flask.jsonify` now correctly does *not* pad its JSON response with
- "jsonp" when the ``padded`` keyword argument is ``False``.
- The :func:`flask.Request.on_json_loading_failed` now returns a JSON formatted
response by default.
- The :func:`flask.url_for` function now can generate anchors to the
View
@@ -135,20 +135,21 @@ def get_current_user():
"""
if __debug__:
_assert_have_json()
- padded = kwargs.pop('padded', False)
- indent = None if request.is_xhr or padded else 2
- mimetype = 'application/json'
- content = json.dumps(dict(*args, **kwargs), indent=indent,
- cls=current_app.json_encoder_class)
- if padded:
- mimetype = 'application/javascript'
- if isinstance(padded, str):
- callback = request.args.get(padded) or 'jsonp'
+ if 'padded' in kwargs:
+ if isinstance(kwargs['padded'], str):
+ callback = request.args.get(kwargs['padded']) or 'jsonp'
else:
- callback = (request.args.get('callback') or
- request.args.get('jsonp') or 'jsonp')
- content = '%s(%s)' % (str(callback), content)
- return current_app.response_class(content, mimetype=mimetype)
+ callback = request.args.get('callback') or \
+ request.args.get('jsonp') or 'jsonp'
+ del kwargs['padded']
+ json_str = json.dumps(dict(*args, **kwargs),
+ cls=current_app.json_encoder_class, indent=None)
+ content = str(callback) + "(" + json_str + ")"
+ return current_app.response_class(content, mimetype='application/javascript')
+ content = json.dumps(dict(*args, **kwargs),
+ cls=current_app.json_encoder_class,
+ indent=None if request.is_xhr else 2)
+ return current_app.response_class(content, mimetype='application/json')
def make_response(*args):

0 comments on commit 1e2aae2

Please sign in to comment.