Opened 10 years ago

Closed 8 years ago

Last modified 8 years 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: Berker Peksag
Component: Documentation Version: dev
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 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Berker Peksag, 8 years ago

Cc: berker.peksag@… added
Has patch: set
Owner: changed from nobody to Berker Peksag
Status: newassigned

comment:3 by Tim Graham, 8 years ago

Patch needs improvement: set

Idea for improvement on the PR.

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 8f50ff5:

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

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 324eaf42:

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

Backport of 8f50ff5b15a742f345dade0848a3fbbf2aff629d from master

comment:6 by Tim Graham <timograham@…>, 8 years ago

In 3b75d126:

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

Backport of 8f50ff5b15a742f345dade0848a3fbbf2aff629d from master

comment:7 by Tim Graham <timograham@…>, 8 years ago

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