aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/content.py
diff options
context:
space:
mode:
authorTom Christie2011-03-13 17:15:50 +0000
committerTom Christie2011-03-13 17:15:50 +0000
commit80e98de9337b7fd735729dbad09d3d629466719c (patch)
treeaecd75826b00d9d69fc4893b8b8df84f580e4243 /djangorestframework/content.py
parent0f0fd13d1358863c2fd92bb75d32d411e84730eb (diff)
parentee74aec27cdc8ca9934f93c828ffbdc7da3c426c (diff)
downloaddjango-rest-framework-80e98de9337b7fd735729dbad09d3d629466719c.tar.bz2
sebpiq's parser improvements
Diffstat (limited to 'djangorestframework/content.py')
-rw-r--r--djangorestframework/content.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/djangorestframework/content.py b/djangorestframework/content.py
index d612a2ee..cfdd33be 100644
--- a/djangorestframework/content.py
+++ b/djangorestframework/content.py
@@ -27,29 +27,31 @@ class StandardContentMixin(ContentMixin):
class OverloadedContentMixin(ContentMixin):
"""HTTP request content behaviour that also allows arbitrary content to be tunneled in form data."""
-
- """The name to use for the content override field in the POST form."""
+
+ """The name to use for the content override field in the POST form.
+ Set this to *None* to desactivate content overloading."""
CONTENT_PARAM = '_content'
- """The name to use for the content-type override field in the POST form."""
+ """The name to use for the content-type override field in the POST form.
+ Taken into account only if content overloading is activated."""
CONTENTTYPE_PARAM = '_contenttype'
def determine_content(self, request):
- """If the request contains content return a tuple of (content_type, content) otherwise return None.
+ """If the request contains content, returns a tuple of (content_type, content) otherwise returns None.
Note that content_type may be None if it is unset."""
if not request.META.get('CONTENT_LENGTH', None) and not request.META.get('TRANSFER_ENCODING', None):
return None
-
content_type = request.META.get('CONTENT_TYPE', None)
if (request.method == 'POST' and self.CONTENT_PARAM and
request.POST.get(self.CONTENT_PARAM, None) is not None):
- # Set content type if form contains a none empty FORM_PARAM_CONTENTTYPE field
+ # Set content type if form contains a non-empty CONTENTTYPE_PARAM field
content_type = None
if self.CONTENTTYPE_PARAM and request.POST.get(self.CONTENTTYPE_PARAM, None):
content_type = request.POST.get(self.CONTENTTYPE_PARAM, None)
+ request.META['CONTENT_TYPE'] = content_type # TODO : VERY BAD, avoid modifying original request.
return (content_type, request.POST[self.CONTENT_PARAM])
-
- return (content_type, request.raw_post_data) \ No newline at end of file
+ else:
+ return (content_type, request.raw_post_data)