mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #5445: added some compatibility code for the lack of __iter__ in Jython 2.2. Thanks, Leo Soto.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6211 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -16,6 +16,7 @@ from django.test import signals
|
||||
from django.utils.functional import curry
|
||||
from django.utils.encoding import smart_str
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.itercompat import is_iterable
|
||||
|
||||
BOUNDARY = 'BoUnDaRyStRiNg'
|
||||
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||
@@ -74,21 +75,22 @@ def encode_multipart(boundary, data):
|
||||
'',
|
||||
value.read()
|
||||
])
|
||||
elif hasattr(value, '__iter__'):
|
||||
for item in value:
|
||||
else:
|
||||
if not isinstance(value, basestring) and is_iterable(value):
|
||||
for item in value:
|
||||
lines.extend([
|
||||
'--' + boundary,
|
||||
'Content-Disposition: form-data; name="%s"' % to_str(key),
|
||||
'',
|
||||
to_str(item)
|
||||
])
|
||||
else:
|
||||
lines.extend([
|
||||
'--' + boundary,
|
||||
'Content-Disposition: form-data; name="%s"' % to_str(key),
|
||||
'',
|
||||
to_str(item)
|
||||
to_str(value)
|
||||
])
|
||||
else:
|
||||
lines.extend([
|
||||
'--' + boundary,
|
||||
'Content-Disposition: form-data; name="%s"' % to_str(key),
|
||||
'',
|
||||
to_str(value)
|
||||
])
|
||||
|
||||
lines.extend([
|
||||
'--' + boundary + '--',
|
||||
|
||||
Reference in New Issue
Block a user