Code

Opened 8 years ago

Closed 7 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: master
Severity: major Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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@…> 8 years ago.
suppress uploadfilecontent?'s display.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Jeong-Min Lee <falsetru@…>

suppress uploadfilecontent?'s display.

comment:1 Changed 8 years ago by Bastian Kleineidam <calvin@…>

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 Changed 8 years ago by adrian

  • Summary changed from [PATCH] repr(uploadfile) should not contain the file content. to [patch] repr(uploadfile) should not contain the file content

comment:3 Changed 7 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 7 years ago by Øyvind Saltvik <oyvind@…>

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [5874]

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.