Ticket #2976: fileupload-repr.patch

File fileupload-repr.patch, 1.7 KB (added by Jeong-Min Lee <falsetru@…>, 18 years ago)

suppress uploadfilecontent's display.

  • http/__init__.py

     
    22from Cookie import SimpleCookie
    33from pprint import pformat
    44from urllib import urlencode, quote
    5 from django.utils.datastructures import MultiValueDict
     5from django.utils.datastructures import MultiValueDict, FileUploadDict
    66
    77RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
    88
     
    6464                # IE submits the full path, so trim everything but the basename.
    6565                # (We can't use os.path.basename because it expects Linux paths.)
    6666                filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:]
    67                 FILES.appendlist(name_dict['name'], {
     67                FILES.appendlist(name_dict['name'], FileUploadDict({
    6868                    'filename': filename,
    6969                    'content-type': (submessage.has_key('Content-Type') and submessage['Content-Type'] or None),
    7070                    'content': submessage.get_payload(),
    71                 })
     71                }))
    7272            else:
    7373                POST.appendlist(name_dict['name'], submessage.get_payload())
    7474    return POST, FILES
  • utils/datastructures.py

     
    242242                current[bits[-1]] = v
    243243            except TypeError: # Special-case if current isn't a dict.
    244244                current = {bits[-1] : v}
     245
     246class FileUploadDict(dict):
     247    def __repr__(self):
     248        copy = self.copy()
     249        copy['content_length'] = len(copy.pop('content'))
     250        return repr(copy)
Back to Top