Ticket #2976: fileupload-repr.patch
File fileupload-repr.patch, 1.7 KB (added by , 18 years ago) |
---|
-
http/__init__.py
2 2 from Cookie import SimpleCookie 3 3 from pprint import pformat 4 4 from urllib import urlencode, quote 5 from django.utils.datastructures import MultiValueDict 5 from django.utils.datastructures import MultiValueDict, FileUploadDict 6 6 7 7 RESERVED_CHARS="!*'();:@&=+$,/?%#[]" 8 8 … … 64 64 # IE submits the full path, so trim everything but the basename. 65 65 # (We can't use os.path.basename because it expects Linux paths.) 66 66 filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:] 67 FILES.appendlist(name_dict['name'], {67 FILES.appendlist(name_dict['name'], FileUploadDict({ 68 68 'filename': filename, 69 69 'content-type': (submessage.has_key('Content-Type') and submessage['Content-Type'] or None), 70 70 'content': submessage.get_payload(), 71 }) 71 })) 72 72 else: 73 73 POST.appendlist(name_dict['name'], submessage.get_payload()) 74 74 return POST, FILES -
utils/datastructures.py
242 242 current[bits[-1]] = v 243 243 except TypeError: # Special-case if current isn't a dict. 244 244 current = {bits[-1] : v} 245 246 class FileUploadDict(dict): 247 def __repr__(self): 248 copy = self.copy() 249 copy['content_length'] = len(copy.pop('content')) 250 return repr(copy)