diff options
| author | tom christie tom@tomchristie.com | 2011-04-26 20:20:31 +0100 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-04-26 20:20:31 +0100 |
| commit | 3d15adaeb11a2f2f2961280026232743afc61398 (patch) | |
| tree | b37c359805420721c52f5637edf191508c663288 /djangorestframework | |
| parent | d0fe36aaa48348874d87202442ea8351b63b0e81 (diff) | |
| download | django-rest-framework-3d15adaeb11a2f2f2961280026232743afc61398.tar.bz2 | |
Fixes #35 - Import json from django's built-in package (Does cleverness in determing best lib to use)
Diffstat (limited to 'djangorestframework')
| -rw-r--r-- | djangorestframework/emitters.py | 8 | ||||
| -rw-r--r-- | djangorestframework/parsers.py | 7 | ||||
| -rw-r--r-- | djangorestframework/tests/authentication.py | 10 | ||||
| -rw-r--r-- | djangorestframework/tests/reverse.py | 6 |
4 files changed, 9 insertions, 22 deletions
diff --git a/djangorestframework/emitters.py b/djangorestframework/emitters.py index 2769a4f5..60a4b5dc 100644 --- a/djangorestframework/emitters.py +++ b/djangorestframework/emitters.py @@ -3,10 +3,11 @@ django-rest-framework also provides HTML and PlainText emitters that help self-d by serializing the output along with documentation regarding the Resource, output status and headers, and providing forms and links depending on the allowed methods, emitters and parsers on the Resource. """ +from django import forms from django.conf import settings from django.http import HttpResponse from django.template import RequestContext, loader -from django import forms +from django.utils import simplejson as json from djangorestframework.response import NoContent, ResponseException from djangorestframework.validators import FormValidatorMixin @@ -21,11 +22,6 @@ import string import re from decimal import Decimal -try: - import json -except ImportError: - import simplejson as json - _MSIE_USER_AGENT = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )') diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py index 1503342c..35003a0f 100644 --- a/djangorestframework/parsers.py +++ b/djangorestframework/parsers.py @@ -9,17 +9,14 @@ We need a method to be able to: and multipart/form-data. (eg also handle multipart/json) """ from django.http.multipartparser import MultiPartParser as DjangoMPParser +from django.utils import simplejson as json + from djangorestframework.response import ResponseException from djangorestframework import status from djangorestframework.utils import as_tuple from djangorestframework.mediatypes import MediaType try: - import json -except ImportError: - import simplejson as json - -try: from urlparse import parse_qs except ImportError: from cgi import parse_qs diff --git a/djangorestframework/tests/authentication.py b/djangorestframework/tests/authentication.py index af9c34ca..246ad4a0 100644 --- a/djangorestframework/tests/authentication.py +++ b/djangorestframework/tests/authentication.py @@ -1,16 +1,14 @@ from django.conf.urls.defaults import patterns -from django.test import TestCase -from django.test import Client +from django.test import Client, TestCase +from django.utils import simplejson as json + from djangorestframework.compat import RequestFactory from djangorestframework.resource import Resource from django.contrib.auth.models import User from django.contrib.auth import login import base64 -try: - import json -except ImportError: - import simplejson as json + class MockResource(Resource): allowed_methods = ('POST',) diff --git a/djangorestframework/tests/reverse.py b/djangorestframework/tests/reverse.py index a862e39a..2718ebca 100644 --- a/djangorestframework/tests/reverse.py +++ b/djangorestframework/tests/reverse.py @@ -1,14 +1,10 @@ from django.conf.urls.defaults import patterns, url from django.core.urlresolvers import reverse from django.test import TestCase +from django.utils import simplejson as json from djangorestframework.resource import Resource -try: - import json -except ImportError: - import simplejson as json - class MockResource(Resource): """Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified""" |
