Opened 18 years ago

Closed 18 years ago

#2878 closed defect (fixed)

Paginator last_on_page fails when .hits hasn't been called

Reported by: sago Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: normal Keywords: paginator
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Because the last_on_page method relies on self._hits, it crashes when self._hits hasn't been set up yet.

This probably hasn't been seen before because most people call paginator.hits (which sets the ._hits attribute) before calling last_on_page.

All that's needed is to make sure ._hits is valid before proceeding. Calls to ._hits could be
exchanged for calls to .hits, but that would involve multiple calls to the property (and therefore the checking logic) in one go. Better, IMHO, to call self.hits once, then use the value throughout the method.

Patch shows this.

Attachments (1)

hit_bugfix.patch (955 bytes ) - added by anonymous 18 years ago.

Download all attachments as: .zip

Change History (4)

by anonymous, 18 years ago

Attachment: hit_bugfix.patch added

comment:1 by Chris Beaven, 18 years ago

Or someone could just apply #2575 which will fix this. However, I won't mark as a dupe because this is fixing a specific problem whereas my one adds some extra functionality as well.

comment:2 by sago, 18 years ago

Agreed, my vote would be to upgrade the paginator generally. Chris, your patch does that to a large extent.

My patch is a minimal fix.

Maybe we should start a thread on django.users about the requirements for the paginator, and collaborate on a general solution that would help everyone. My requirements may be slightly different from yours, etc. Then we can remove all paginator patches (there are a handful) and submit a canonical solution.

comment:3 by Chris Beaven, 18 years ago

Resolution: fixed
Status: newclosed

I'm pretty sure this has been fixed now #2575 has been applied. If you still can identify a problem, please re-open.

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