Skip to content

Commit

Permalink
Tiny refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Apr 20, 2010
1 parent eae44e4 commit af3b73f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
pkg_resources = None


# figure out if simplejson escapes slashes. This behaviour was changed
# from one version to another without reason.
_json_escapes_slashes = json_available and '\\/' in json.dumps('/')


class Request(RequestBase):
"""The request object used by default in flask. Remembers the
matched endpoint and view arguments.
Expand Down Expand Up @@ -272,12 +267,13 @@ def _get_package_path(name):
return os.getcwd()


if not _json_escapes_slashes:
def _tojson_filter(string, *args, **kwargs):
"""Calls dumps for the template engine, escaping slashes properly."""
# figure out if simplejson escapes slashes. This behaviour was changed
# from one version to another without reason.
if not json_available or '\\/' not in json.dumps('/'):
def _tojson_filter(*args, **kwargs):
if __debug__:
_assert_have_json()
return json.dumps(string, *args, **kwargs).replace('/', '\\/')
return json.dumps(*args, **kwargs).replace('/', '\\/')
else:
_tojson_filter = json.dumps

Expand Down

0 comments on commit af3b73f

Please sign in to comment.