summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-07-18 05:52:06 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-07-18 05:52:06 +0000
commitac2a7c116dcc0591c5cb55f75b687ef9e8be632e (patch)
tree24e56c7bed1e2618a6afc10970058ca4a891919c
parentf3a43a2dd4b111fdf330c023478d586b3f015546 (diff)
Changed django.utils.httpwrappers.parse_file_upload() NOT to be coupled to mod_python
git-svn-id: http://code.djangoproject.com/svn/django/trunk@165 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/httpwrappers.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/django/utils/httpwrappers.py b/django/utils/httpwrappers.py
index 513a5bc0d7..764b29ec1c 100644
--- a/django/utils/httpwrappers.py
+++ b/django/utils/httpwrappers.py
@@ -40,7 +40,7 @@ class ModPythonRequest(HttpRequest):
def _load_post_and_files(self):
"Populates self._post and self._files"
if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'):
- self._post, self._files = parse_file_upload(self._req)
+ self._post, self._files = parse_file_upload(self._req.headers_in, self._req.read())
else:
self._post, self._files = QueryDict(self._req.read()), datastructures.MultiValueDict()
@@ -112,12 +112,12 @@ class ModPythonRequest(HttpRequest):
META = property(_get_meta)
REQUEST = property(_get_request)
-def parse_file_upload(req):
- "Returns a tuple of (POST MultiValueDict, FILES MultiValueDict), given a mod_python req object"
+def parse_file_upload(header_dict, post_data):
+ "Returns a tuple of (POST MultiValueDict, FILES MultiValueDict)"
import email, email.Message
from cgi import parse_header
- raw_message = '\r\n'.join(['%s:%s' % pair for pair in req.headers_in.items()])
- raw_message += '\r\n\r\n' + req.read()
+ raw_message = '\r\n'.join(['%s:%s' % pair for pair in header_dict.items()])
+ raw_message += '\r\n\r\n' + post_data
msg = email.message_from_string(raw_message)
POST = datastructures.MultiValueDict()
FILES = datastructures.MultiValueDict()