Opened 6 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#36587 closed Cleanup/optimization (fixed)

Misleading sentence in documentation about upload handlers

Reported by: Baptiste Mispelon Owned by: Chaitanya Keyal
Component: Documentation Version: 5.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Natalia Bidart)

The documentation about changing upload handlers on the fly states:

For instance, suppose you’ve written a ProgressBarUploadHandler that provides feedback on upload progress to some sort of AJAX widget. You’d add this handler to your upload handlers like this:
request.upload_handlers.insert(0, ProgressBarUploadHandler(request))
You’d probably want to use list.insert() in this case (instead of append()) because a progress bar handler would need to run before any other handlers. Remember, the upload handlers are processed in order.

The part that says "You'd probably want to use list.insert [...] (instead of append)" is incorrect, since the example is already using list.insert. The sentence should just say something like:

We use list.insert to make sure the progress bar handler is run before any other handlers, since the upload handlers are processed in order.

Change History (10)

comment:1 by Tim Graham, 6 weeks ago

I wouldn't say it's incorrect. I think the meaning is that "[In this hypothetical example,] you'd probably want to [and this example does] use..." but if you found it confusing, perhaps it's fine to change. I'd try to avoid "We" since that's not really the documentation's style.

comment:2 by Natalia Bidart, 6 weeks ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

Thank you Baptiste, I see the oddity in the phrasing, though I also understand Tim's point that the sentence is trying to say "do not use append here even if you are tempted to do so".

Accepting since this could be better phrased, my proposal (as a starting point):

Using list.insert(), as shown above, ensures that the progress bar handler is placed at the beginning of the list. Since upload handlers are executed in order, this placement guarantees that the progress bar handler runs before the default handlers, allowing it to track progress across the entire upload.

comment:3 by Natalia Bidart, 6 weeks ago

Summary: Incorrect sentence in documentation about upload handlersMisleading sentence in documentation about upload handlers

comment:4 by Natalia Bidart, 6 weeks ago

Type: BugCleanup/optimization

comment:5 by Chaitanya Keyal, 6 weeks ago

Owner: set to Chaitanya Keyal
Status: newassigned

comment:6 by Chaitanya Keyal, 6 weeks ago

Has patch: set

comment:7 by Sarah Boyce, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In afe6634:

Fixed #36587 -- Clarified usage of list.insert() for upload handlers.

Thanks Baptiste Mispelon for the report

Co-authored-by: Natalia <124304+nessita@…>

comment:9 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

In 01515099:

[6.0.x] Fixed #36587 -- Clarified usage of list.insert() for upload handlers.

Thanks Baptiste Mispelon for the report

Co-authored-by: Natalia <124304+nessita@…>

Backport of afe6634146d0fe70498976c49d2eb4d745aa9064 from main.

comment:10 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

In 81625a1:

[5.2.x] Fixed #36587 -- Clarified usage of list.insert() for upload handlers.

Thanks Baptiste Mispelon for the report

Co-authored-by: Natalia <124304+nessita@…>

Backport of afe6634146d0fe70498976c49d2eb4d745aa9064 from main.

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