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
91ba2717
Commit
91ba2717
authored
Apr 27, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2858 from kazmiruk/version-2.4.x
change SortedDict to OrderedDict + fix list and tuple concatination
parents
4a75a9c0
fad0848b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
12 deletions
+44
-12
rest_framework/compat.py
+27
-0
rest_framework/fields.py
+1
-2
rest_framework/routers.py
+1
-1
rest_framework/serializers.py
+10
-3
rest_framework/settings.py
+2
-1
rest_framework/utils/encoders.py
+1
-2
rest_framework/views.py
+1
-2
tests/test_fields.py
+1
-1
No files found.
rest_framework/compat.py
View file @
91ba2717
...
@@ -265,3 +265,30 @@ except ImportError:
...
@@ -265,3 +265,30 @@ except ImportError:
klass
.
__unicode__
=
klass
.
__str__
klass
.
__unicode__
=
klass
.
__str__
klass
.
__str__
=
lambda
self
:
self
.
__unicode__
()
.
encode
(
'utf-8'
)
klass
.
__str__
=
lambda
self
:
self
.
__unicode__
()
.
encode
(
'utf-8'
)
return
klass
return
klass
"""
SortedDict deprecated since django 1.8. There is collections.OrderedDict
which available since python 2.7 and python 3.1. There are no need of other
checks because of django 1.7+ requires python 2.7+
"""
try
:
from
collections
import
OrderedDict
as
SortedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
"""
GenericForeignKey moves from generic to fields in django 1.9 and in 1.8 shows
deprecation warnings
"""
if
django
.
VERSION
>=
(
1
,
8
):
from
django.contrib.contenttypes.fields
import
GenericForeignKey
else
:
from
django.contrib.contenttypes.generic
import
GenericForeignKey
"""
django.utils.importlib is deprecated since django 1.8
"""
try
:
import
importlib
except
ImportError
:
from
django.utils
import
importlib
rest_framework/fields.py
View file @
91ba2717
...
@@ -22,11 +22,10 @@ from django.forms import widgets
...
@@ -22,11 +22,10 @@ from django.forms import widgets
from
django.utils
import
six
,
timezone
from
django.utils
import
six
,
timezone
from
django.utils.encoding
import
is_protected_type
from
django.utils.encoding
import
is_protected_type
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.datastructures
import
SortedDict
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
rest_framework
import
ISO_8601
from
rest_framework
import
ISO_8601
from
rest_framework.compat
import
(
from
rest_framework.compat
import
(
BytesIO
,
smart_text
,
BytesIO
,
smart_text
,
SortedDict
,
force_text
,
is_non_str_iterable
force_text
,
is_non_str_iterable
)
)
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
...
...
rest_framework/routers.py
View file @
91ba2717
...
@@ -20,8 +20,8 @@ from collections import namedtuple
...
@@ -20,8 +20,8 @@ from collections import namedtuple
from
django.conf.urls
import
patterns
,
url
from
django.conf.urls
import
patterns
,
url
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
NoReverseMatch
from
django.core.urlresolvers
import
NoReverseMatch
from
django.utils.datastructures
import
SortedDict
from
rest_framework
import
views
from
rest_framework
import
views
from
rest_framework.compat
import
SortedDict
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.reverse
import
reverse
from
rest_framework.reverse
import
reverse
from
rest_framework.urlpatterns
import
format_suffix_patterns
from
rest_framework.urlpatterns
import
format_suffix_patterns
...
...
rest_framework/serializers.py
View file @
91ba2717
...
@@ -16,14 +16,13 @@ import datetime
...
@@ -16,14 +16,13 @@ import datetime
import
inspect
import
inspect
import
types
import
types
from
decimal
import
Decimal
from
decimal
import
Decimal
from
django.contrib.contenttypes.generic
import
GenericForeignKey
from
django.core.paginator
import
Page
from
django.core.paginator
import
Page
from
django.db
import
models
from
django.db
import
models
from
django.forms
import
widgets
from
django.forms
import
widgets
from
django.utils
import
six
from
django.utils
import
six
from
django.utils.datastructures
import
SortedDict
from
django.utils.functional
import
cached_property
from
django.utils.functional
import
cached_property
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
rest_framework.compat
import
SortedDict
,
GenericForeignKey
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
...
@@ -110,9 +109,17 @@ class SortedDictWithMetadata(SortedDict):
...
@@ -110,9 +109,17 @@ class SortedDictWithMetadata(SortedDict):
"""
"""
A sorted dict-like object, that can have additional properties attached.
A sorted dict-like object, that can have additional properties attached.
"""
"""
def
__reduce__
(
self
):
"""
Used by pickle (e.g., caching) if OrderedDict is used instead of SortedDict
Overriden to remove the metadata from the dict, since it shouldn't be
pickle and may in some instances be unpickleable.
"""
return
self
.
__class__
,
(
SortedDict
(
self
),
)
def
__getstate__
(
self
):
def
__getstate__
(
self
):
"""
"""
Used by pickle (e.g., caching)
.
Used by pickle (e.g., caching)
in SortedDict
Overriden to remove the metadata from the dict, since it shouldn't be
Overriden to remove the metadata from the dict, since it shouldn't be
pickle and may in some instances be unpickleable.
pickle and may in some instances be unpickleable.
"""
"""
...
...
rest_framework/settings.py
View file @
91ba2717
...
@@ -19,8 +19,9 @@ back to the defaults.
...
@@ -19,8 +19,9 @@ back to the defaults.
"""
"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
importlib
,
six
from
django.utils
import
six
from
rest_framework
import
ISO_8601
from
rest_framework
import
ISO_8601
from
rest_framework.compat
import
importlib
USER_SETTINGS
=
getattr
(
settings
,
'REST_FRAMEWORK'
,
None
)
USER_SETTINGS
=
getattr
(
settings
,
'REST_FRAMEWORK'
,
None
)
...
...
rest_framework/utils/encoders.py
View file @
91ba2717
...
@@ -4,9 +4,8 @@ Helper classes for parsers.
...
@@ -4,9 +4,8 @@ Helper classes for parsers.
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.db.models.query
import
QuerySet
from
django.db.models.query
import
QuerySet
from
django.utils.datastructures
import
SortedDict
from
django.utils.functional
import
Promise
from
django.utils.functional
import
Promise
from
rest_framework.compat
import
force_text
from
rest_framework.compat
import
force_text
,
SortedDict
from
rest_framework.serializers
import
DictWithMetadata
,
SortedDictWithMetadata
from
rest_framework.serializers
import
DictWithMetadata
,
SortedDictWithMetadata
import
datetime
import
datetime
import
decimal
import
decimal
...
...
rest_framework/views.py
View file @
91ba2717
...
@@ -5,10 +5,9 @@ from __future__ import unicode_literals
...
@@ -5,10 +5,9 @@ from __future__ import unicode_literals
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.http
import
Http404
from
django.utils.datastructures
import
SortedDict
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework
import
status
,
exceptions
from
rest_framework
import
status
,
exceptions
from
rest_framework.compat
import
smart_text
,
HttpResponseBase
,
View
from
rest_framework.compat
import
smart_text
,
HttpResponseBase
,
SortedDict
,
View
from
rest_framework.request
import
Request
from
rest_framework.request
import
Request
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
...
...
tests/test_fields.py
View file @
91ba2717
...
@@ -10,8 +10,8 @@ from uuid import uuid4
...
@@ -10,8 +10,8 @@ from uuid import uuid4
from
django.core
import
validators
from
django.core
import
validators
from
django.db
import
models
from
django.db
import
models
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils.datastructures
import
SortedDict
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
rest_framework.compat
import
SortedDict
from
tests.models
import
RESTFrameworkModel
from
tests.models
import
RESTFrameworkModel
...
...
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