Opened 18 years ago

Closed 18 years ago

#4053 closed (invalid)

implicitly control in paginator causes unexpected return values.

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

Description

Hi,

Pagiantor doesn't check the 'page_number' value in "has_next_page" and "has_previous_page" functions. It causes this:

>>> from django.core.paginator import ObjectPaginator
>>> from zangetsu.blog.models import Entry
>>> e = Entry.objects.all()
>>> len(e)
262
>>> paginator_result = ObjectPaginator(e, 10)
>>> paginator_result.pages
27
>>> page_number = 0
>>> paginator_result.has_next_page(page_number)
True
>>> paginator_result.has_previous_page(page_number)
False
>>> page_number = "0"
>>> paginator_result.has_next_page(page_number)
False
>>> paginator_result.has_previous_page(page_number)
True

Please review the patch attached below (I'm sorry if ticket is in the wrong component, I couldn't find any closer).

Thanks,

  1. Murat Eren.

Attachments (1)

paginator-check_int.diff (942 bytes ) - added by meren@… 18 years ago.

Download all attachments as: .zip

Change History (2)

by meren@…, 18 years ago

Attachment: paginator-check_int.diff added

comment:1 by Brian Rosner <brosner@…>, 18 years ago

Resolution: invalid
Status: newclosed

I think in this case that the type conversion should be done before passing it in to has_*_page methods. These methods shouldn't care where the data came from.

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