Opened 3 years ago

Closed 3 months ago

Last modified 3 months ago

#21588 closed Cleanup/optimization (fixed)

"Modifying upload handlers on the fly" documentation doesn't replicate internal magic

Reported by: Keryn Knight <django@…> Owned by: berkerpeksag
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: berker.peksag@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In the documentation for modifying upload handlers on a per-request basis, the examples given imply that simply instantiating a Handler onto the upload_handlers is equivalent to setting them globally via FILE_UPLOAD_HANDLERS, however this isn't the case, because the _initialize_handlers method of HttpRequest passes self (ie: the request parameter in userland code) to the given handler.

Thus copying or subclassing from one of the default handlers doesn't necessarily work as expected because request is always None - which is perfectly valid according to the arguments for, say, FileUploadHandler.

It would be prudent to note that custom handlers, if they need arguments (including request), should do so at the time of instantiation onto the upload_handlers list

Change History (7)

comment:1 Changed 3 years ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 months ago by berkerpeksag

  • Cc berker.peksag@… added
  • Has patch set
  • Owner changed from nobody to berkerpeksag
  • Status changed from new to assigned

comment:3 Changed 3 months ago by timgraham

  • Patch needs improvement set

Idea for improvement on the PR.

comment:4 Changed 3 months ago by Tim Graham <timograham@…>

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

In 8f50ff5:

Fixed #21588 -- Corrected handler initialization in "modifying upload handlers" example.

comment:5 Changed 3 months ago by Tim Graham <timograham@…>

In 324eaf42:

[1.9.x] Fixed #21588 -- Corrected handler initialization in "modifying upload handlers" example.

Backport of 8f50ff5b15a742f345dade0848a3fbbf2aff629d from master

comment:6 Changed 3 months ago by Tim Graham <timograham@…>

In 3b75d126:

[1.10.x] Fixed #21588 -- Corrected handler initialization in "modifying upload handlers" example.

Backport of 8f50ff5b15a742f345dade0848a3fbbf2aff629d from master

comment:7 Changed 3 months ago by Tim Graham <timograham@…>

In ba29dfb1:

[1.8.x] Fixed #21588 -- Corrected handler initialization in "modifying upload handlers" example.

Backport of 8f50ff5b15a742f345dade0848a3fbbf2aff629d from master

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