Opened 18 years ago

Closed 17 years ago

#2976 closed defect (fixed)

[patch] repr(uploadfile) should not contain the file content

Reported by: Jeong-Min Lee <falsetru@…> Owned by: nobody
Component: Core (Other) Version: dev
Severity: major Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If uploadfilecontent is very long, repr(uploadfile) produce non-readable stuff.
It sometimes make a browser hang.

A significant performance problem occur on following scenario.

  1. You have a model that has many nullable/blankable fields with a FileField.
  2. You upload big file, without filling nullable fields.
  3. In view, manipulator.save is called.
  4. for each field, validation is called.
  5. for nullable field, while getting field from new_data, repr(new_data) is called, which trigger repr(upload_file)
  6. repr(upload_file) is very long. It is called for each nullable field. this take long time. (taked 4s~12s for my app)

Sorry for my poor explanation.

Attachments (1)

fileupload-repr.patch (1.7 KB ) - added by Jeong-Min Lee <falsetru@…> 18 years ago.
suppress uploadfilecontent's display.

Download all attachments as: .zip

Change History (5)

by Jeong-Min Lee <falsetru@…>, 18 years ago

Attachment: fileupload-repr.patch added

suppress uploadfilecontent's display.

comment:1 by Bastian Kleineidam <calvin@…>, 18 years ago

I think it would be helpful to at least display some content of the file, eg. the first 40-60 characters.
Something like this would work:

clen = len(filedict["content"])
if clen > 40:
    suffix = "... and %d more" % (clen - 40)
    copy["content"] = filedict["content"][:40] + suffix

comment:2 by Adrian Holovaty, 18 years ago

Summary: [PATCH] repr(uploadfile) should not contain the file content.[patch] repr(uploadfile) should not contain the file content

comment:3 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:4 by Øyvind Saltvik <oyvind@…>, 17 years ago

Resolution: fixed
Status: newclosed

Fixed in [5874]

Note: See TracTickets for help on using tickets.
Back to Top