#21588 closed Cleanup/optimization (fixed)
"Modifying upload handlers on the fly" documentation doesn't replicate internal magic
| Reported by: | 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 , 12 years ago
| Triage Stage: | Unreviewed → Accepted | 
|---|
comment:2 by , 9 years ago
| Cc: | added | 
|---|---|
| Has patch: | set | 
| Owner: | changed from to | 
| Status: | new → assigned | 
https://github.com/django/django/pull/6722