On 6/15/07, Christoph Haas <[EMAIL PROTECTED]> wrote: > > On Fri, Jun 15, 2007 at 12:08:31PM -0700, Mike Orr wrote: > > There's a bug in Christoph Haas's alternative paginator > > (http://workaround.org/pylons/paginator/) > > if the result set contains zero records and 'show_if_single_page' is true. > > > > Module inews.lib.paginator:245 in navigator > > text = '%s' % (self.first_page+(start_with_one and 1)) > > TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' > > Oops. > > > self.first_page was set to None in line 121. > > > > I think the solution is to add a stanza after this one: > > > > # Don't show navigator if there is no more than one page > > if self.page_count <= 1 and show_if_single_page == False: > > return '' > > > > adding at line 237: > > > > # If zero result records, return a fake navigator > > return '<strong>[1]</strong>' > > Not sure what's better. If there's nothing to navigate I personally > prefer not to see a useless navigator. But I think I can make this > behavior customizable through options.
If they haven't passed 'show_if_single_page', they'll still get an empty navigator. I tried it originally that way but found it jarring to have a navigator that sometimes disappears: it makes you wonder if something's broken. In a normal case the programmer probably checks for no records and displays a "No records" message, bypassing the pager completely, but the pager must still be able to handle this case anyway. I've also put extra info around my navigator in a subclass: Displaying records 21 to 40 of 2754. Page: 1 [2] ... > I'll fix that shortly. I have added support for jQuery, too, because I > have averted from scriptaculous/prototype. There's still your question > on my list on how to degrade gracefully if there is no Javascript > support (as you asked for recently) anyway. Suggestions welcome if > anyone's quicker. It looks like webhelpers.link_to_remote() can take an href= keyword argument for the fallback URL. I'll try it when I have a moment. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
