Opened 19 months ago

Last modified 19 months ago

#21588 new Cleanup/optimization

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

Reported by: Keryn Knight <django@…> Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
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 (1)

comment:1 Changed 19 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
Note: See TracTickets for help on using tickets.
Back to Top