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
a31a68d6
Commit
a31a68d6
authored
May 12, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
yet more API cleanup
parent
b5b231a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
djangorestframework/mixins.py
+11
-4
No files found.
djangorestframework/mixins.py
View file @
a31a68d6
...
@@ -54,7 +54,7 @@ class RequestMixin(object):
...
@@ -54,7 +54,7 @@ class RequestMixin(object):
Returns the HTTP method.
Returns the HTTP method.
"""
"""
if
not
hasattr
(
self
,
'_method'
):
if
not
hasattr
(
self
,
'_method'
):
self
.
_
method
=
self
.
request
.
method
self
.
_
load_metadata
()
return
self
.
_method
return
self
.
_method
...
@@ -64,7 +64,7 @@ class RequestMixin(object):
...
@@ -64,7 +64,7 @@ class RequestMixin(object):
Returns the content type header.
Returns the content type header.
"""
"""
if
not
hasattr
(
self
,
'_content_type'
):
if
not
hasattr
(
self
,
'_content_type'
):
self
.
_
content_type
=
self
.
request
.
META
.
get
(
'HTTP_CONTENT_TYPE'
,
self
.
request
.
META
.
get
(
'CONTENT_TYPE'
,
''
)
)
self
.
_
load_metadata
(
)
return
self
.
_content_type
return
self
.
_content_type
...
@@ -95,6 +95,14 @@ class RequestMixin(object):
...
@@ -95,6 +95,14 @@ class RequestMixin(object):
stream
=
self
.
_get_stream
()
stream
=
self
.
_get_stream
()
(
self
.
_data
,
self
.
_files
)
=
self
.
_parse
(
stream
,
self
.
content_type
)
(
self
.
_data
,
self
.
_files
)
=
self
.
_parse
(
stream
,
self
.
content_type
)
def
_load_metadata
(
self
):
"""
Set the method and content_type and then check if they've been overridden.
"""
self
.
_method
=
self
.
request
.
method
self
.
_content_type
=
self
.
request
.
META
.
get
(
'HTTP_CONTENT_TYPE'
,
self
.
request
.
META
.
get
(
'CONTENT_TYPE'
,
''
))
self
.
_perform_form_overloading
()
def
_get_stream
(
self
):
def
_get_stream
(
self
):
"""
"""
...
@@ -161,8 +169,7 @@ class RequestMixin(object):
...
@@ -161,8 +169,7 @@ class RequestMixin(object):
"""
"""
# We only need to use form overloading on form POST requests
# We only need to use form overloading on form POST requests
content_type
=
self
.
request
.
META
.
get
(
'HTTP_CONTENT_TYPE'
,
self
.
request
.
META
.
get
(
'CONTENT_TYPE'
,
''
))
if
not
self
.
_USE_FORM_OVERLOADING
or
self
.
_method
!=
'POST'
or
not
not
is_form_media_type
(
self
.
_content_type
):
if
not
self
.
_USE_FORM_OVERLOADING
or
self
.
request
.
method
!=
'POST'
or
not
not
is_form_media_type
(
content_type
):
return
return
# Temporarily switch to using the form parsers, then parse the content
# Temporarily switch to using the form parsers, then parse the content
...
...
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