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
cb7d9ea5
Commit
cb7d9ea5
authored
Dec 06, 2012
by
Ben Roberts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up white space & docstring styling
parent
7f28a784
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
rest_framework/serializers.py
+4
-5
rest_framework/tests/serializer.py
+8
-6
No files found.
rest_framework/serializers.py
View file @
cb7d9ea5
...
...
@@ -22,11 +22,11 @@ class DictWithMetadata(dict):
"""
A dict-like object, that can have additional properties attached.
"""
def
__getstate__
(
self
):
""" Used by pickle (e.g., caching).
Overriden to remove metadata from the dict, since it shouldn't be pickled
and may in some instances be unpickleable.
"""
Used by pickle (e.g., caching).
Overriden to remove metadata from the dict, since it shouldn't be pickled
and may in some instances be unpickleable.
"""
# return an instance of the first dict in MRO that isn't a DictWithMetadata
for
base
in
self
.
__class__
.
__mro__
:
...
...
@@ -41,7 +41,6 @@ class SortedDictWithMetadata(SortedDict, DictWithMetadata):
pass
def
_is_protected_type
(
obj
):
"""
True if the object is a native datatype that does not need to
...
...
rest_framework/tests/serializer.py
View file @
cb7d9ea5
...
...
@@ -645,18 +645,20 @@ class BlankFieldTests(TestCase):
#test for issue #460
class
SerializerPickleTests
(
TestCase
):
""" Test pickleability of the output of Serializers
"""
Test pickleability of the output of Serializers
"""
def
test_pickle_simple_model_serializer_data
(
self
):
""" Test simple serializer
"""
Test simple serializer
"""
pickle
.
dumps
(
PersonSerializer
(
Person
(
name
=
"Methusela"
,
age
=
969
))
.
data
)
def
test_pickle_inner_serializer
(
self
):
""" Test pickling a serializer whose resulting .data (a SortedDictWithMetadata) will
have unpickleable meta data--in order to make sure metadata doesn't get pulled into the pickle.
See DictWithMetadata.__getstate__
"""
Test pickling a serializer whose resulting .data (a SortedDictWithMetadata) will
have unpickleable meta data--in order to make sure metadata doesn't get pulled into the pickle.
See DictWithMetadata.__getstate__
"""
class
InnerPersonSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
...
...
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