Restored 2.5 compatibility and actual fix for the json problem

This commit is contained in:
Armin Ronacher 2010-07-04 20:07:03 +02:00
parent 80eb6cfffc
commit 51a89bf35e
4 changed files with 9 additions and 4 deletions

2
.gitignore vendored
View file

@ -2,6 +2,8 @@
*.pyc *.pyc
*.pyo *.pyo
env env
env*
dist dist
*.egg
*.egg-info *.egg-info
_mailinglist _mailinglist

View file

@ -19,6 +19,7 @@ from zlib import adler32
# try to load the best simplejson implementation available. If JSON # try to load the best simplejson implementation available. If JSON
# is not installed, we add a failing class. # is not installed, we add a failing class.
json_available = True json_available = True
json = None
try: try:
import simplejson as json import simplejson as json
except ImportError: except ImportError:
@ -32,7 +33,6 @@ from werkzeug import Headers, wrap_file, is_resource_modified, cached_property
from jinja2 import FileSystemLoader from jinja2 import FileSystemLoader
from .globals import session, _request_ctx_stack, current_app, request from .globals import session, _request_ctx_stack, current_app, request
from .wrappers import Response
def _assert_have_json(): def _assert_have_json():
@ -364,3 +364,7 @@ class _PackageBoundObject(object):
subfolders use forward slashes as separator. subfolders use forward slashes as separator.
""" """
return open(os.path.join(self.root_path, resource), 'rb') return open(os.path.join(self.root_path, resource), 'rb')
# circular dependencies between wrappers and helpers
from .wrappers import Response

View file

@ -9,7 +9,7 @@
:license: BSD, see LICENSE for more details. :license: BSD, see LICENSE for more details.
""" """
from flask.helpers import _PackageBoundObject from .helpers import _PackageBoundObject
def _register_module(module, static_path): def _register_module(module, static_path):

View file

@ -12,7 +12,7 @@
from werkzeug import Request as RequestBase, Response as ResponseBase, \ from werkzeug import Request as RequestBase, Response as ResponseBase, \
cached_property cached_property
from .helpers import json from .helpers import json, _assert_have_json
class Request(RequestBase): class Request(RequestBase):
@ -52,7 +52,6 @@ class Request(RequestBase):
parsed JSON data. parsed JSON data.
""" """
if __debug__: if __debug__:
from flask.helpers import _assert_have_json
_assert_have_json() _assert_have_json()
if self.mimetype == 'application/json': if self.mimetype == 'application/json':
return json.loads(self.data) return json.loads(self.data)