Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
762a52ed
Commit
762a52ed
authored
Apr 25, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some compat issues with json/simplejson
parent
84a4fd3e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
39 deletions
+30
-39
djangorestframework/compat.py
+10
-2
djangorestframework/emitters.py
+1
-5
djangorestframework/parsers.py
+3
-10
djangorestframework/tests/authentication.py
+6
-6
djangorestframework/tests/reverse.py
+1
-4
examples/blogpost/tests.py
+5
-8
examples/pygments_api/tests.py
+4
-4
No files found.
djangorestframework/compat.py
View file @
762a52ed
...
@@ -125,4 +125,12 @@ except:
...
@@ -125,4 +125,12 @@ except:
# 'request': self.request
# 'request': self.request
# }
# }
#)
#)
return
http
.
HttpResponseNotAllowed
(
allowed_methods
)
return
http
.
HttpResponseNotAllowed
(
allowed_methods
)
\ No newline at end of file
# parse_qs
try
:
# python >= ?
from
urlparse
import
parse_qs
except
ImportError
:
# python <= ?
from
cgi
import
parse_qs
\ No newline at end of file
djangorestframework/emitters.py
View file @
762a52ed
...
@@ -5,6 +5,7 @@ and providing forms and links depending on the allowed methods, emitters and par
...
@@ -5,6 +5,7 @@ and providing forms and links depending on the allowed methods, emitters and par
"""
"""
from
django.conf
import
settings
from
django.conf
import
settings
from
django.template
import
RequestContext
,
loader
from
django.template
import
RequestContext
,
loader
from
django.utils
import
simplejson
as
json
from
django
import
forms
from
django
import
forms
from
djangorestframework.response
import
ErrorResponse
from
djangorestframework.response
import
ErrorResponse
...
@@ -18,11 +19,6 @@ from urllib import quote_plus
...
@@ -18,11 +19,6 @@ from urllib import quote_plus
import
string
import
string
import
re
import
re
try
:
import
json
except
ImportError
:
import
simplejson
as
json
# TODO: Rename verbose to something more appropriate
# TODO: Rename verbose to something more appropriate
...
...
djangorestframework/parsers.py
View file @
762a52ed
...
@@ -9,20 +9,13 @@ We need a method to be able to:
...
@@ -9,20 +9,13 @@ We need a method to be able to:
and multipart/form-data. (eg also handle multipart/json)
and multipart/form-data. (eg also handle multipart/json)
"""
"""
from
django.http.multipartparser
import
MultiPartParser
as
DjangoMPParser
from
django.http.multipartparser
import
MultiPartParser
as
DjangoMPParser
from
django.utils
import
simplejson
as
json
from
djangorestframework.response
import
ErrorResponse
from
djangorestframework.response
import
ErrorResponse
from
djangorestframework
import
status
from
djangorestframework
import
status
from
djangorestframework.utils
import
as_tuple
from
djangorestframework.utils
import
as_tuple
from
djangorestframework.mediatypes
import
MediaType
from
djangorestframework.mediatypes
import
MediaType
from
djangorestframework.compat
import
parse_qs
try
:
import
json
except
ImportError
:
import
simplejson
as
json
try
:
from
urlparse
import
parse_qs
except
ImportError
:
from
cgi
import
parse_qs
...
...
djangorestframework/tests/authentication.py
View file @
762a52ed
from
django.conf.urls.defaults
import
patterns
from
django.conf.urls.defaults
import
patterns
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test
import
Client
from
django.test
import
Client
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.resource
import
Resource
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
login
from
django.contrib.auth
import
login
from
django.utils
import
simplejson
as
json
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.resource
import
Resource
import
base64
import
base64
try
:
import
json
except
ImportError
:
import
simplejson
as
json
class
MockResource
(
Resource
):
class
MockResource
(
Resource
):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
...
@@ -86,3 +85,4 @@ class SessionAuthTests(TestCase):
...
@@ -86,3 +85,4 @@ class SessionAuthTests(TestCase):
"""Ensure POSTing form over session authentication without logged in user fails."""
"""Ensure POSTing form over session authentication without logged in user fails."""
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
djangorestframework/tests/reverse.py
View file @
762a52ed
from
django.conf.urls.defaults
import
patterns
,
url
from
django.conf.urls.defaults
import
patterns
,
url
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils
import
simplejson
as
json
from
djangorestframework.resource
import
Resource
from
djangorestframework.resource
import
Resource
try
:
import
json
except
ImportError
:
import
simplejson
as
json
class
MockResource
(
Resource
):
class
MockResource
(
Resource
):
...
...
examples/blogpost/tests.py
View file @
762a52ed
"""Test a range of REST API usage of the example application.
"""Test a range of REST API usage of the example application.
"""
"""
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.utils
import
simplejson
as
json
from
djangorestframework.compat
import
RequestFactory
from
blogpost
import
views
,
models
from
blogpost
import
views
,
models
import
blogpost
import
blogpost
#import json
#from rest.utils import xml2dict, dict2xml
class
AcceptHeaderTests
(
TestCase
):
class
AcceptHeaderTests
(
TestCase
):
"""Test correct behaviour of the Accept header as specified by RFC 2616:
"""Test correct behaviour of the Accept header as specified by RFC 2616:
...
@@ -164,11 +166,6 @@ class AllowedMethodsTests(TestCase):
...
@@ -164,11 +166,6 @@ class AllowedMethodsTests(TestCase):
#above testcases need to probably moved to the core
#above testcases need to probably moved to the core
from
djangorestframework.compat
import
RequestFactory
try
:
import
json
except
ImportError
:
import
simplejson
as
json
class
TestRotation
(
TestCase
):
class
TestRotation
(
TestCase
):
"""For the example the maximum amount of Blogposts is capped off at views.MAX_POSTS.
"""For the example the maximum amount of Blogposts is capped off at views.MAX_POSTS.
...
...
examples/pygments_api/tests.py
View file @
762a52ed
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils
import
simplejson
as
json
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.compat
import
RequestFactory
from
pygments_api
import
views
from
pygments_api
import
views
import
tempfile
,
shutil
import
tempfile
,
shutil
try
:
import
json
except
ImportError
:
import
simplejson
as
json
class
TestPygmentsExample
(
TestCase
):
class
TestPygmentsExample
(
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment