Module reahl.web.pager

Tools for breaking long lists into shorter lists that can be paged.

PagedPanel

class reahl.web.pager.PagedPanel(view, page_index, css_id)

A Panel whose contents change, depending on the page selected by a user from a PageMenu. A programmer should subclass from PagedPanel, supplying an __init__ method which populates the PagedPanel with appropriate contents, based on its .current_contents.

Styling

Represented in HTML by an <div> element.

Parameters:
  • view – (See reahl.web.fw.Widget)
  • page_index – The PageIndex to use to supply contents to the pages displayed by this PagedPanel.
  • css_id – (See HTMLElement)
current_contents

The list of items that should be displayed for the current page.

PageIndex

class reahl.web.pager.PageIndex(current_page_number=1, start_page_number=1, max_page_links=5)

An object responsible for breaking a long list of items up into shorter lists for display. Each such shorter list is referred to as a page. Different ways of breaking long lists into smaller lists are provided by subclasses.

Parameters:
  • current_page_number – The initial page shown to users.
  • start_page_number – The first page that should be listed in the current PageMenu.
  • max_page_links – The number of pages to be shown in the current PageMenu.
get_contents_for_page(page_number)

Override this method in subclasses to obtain the correct list of items for the given page_number.

total_number_of_pages

Override this @property in subclasses to state what the total number of pages is.

SequentialPageIndex

class reahl.web.pager.SequentialPageIndex(items, items_per_page=5, current_page_number=1, start_page_number=1, max_page_links=4)

A PageIndex that breaks a list of items up into smaller lists, by cutting the original list into sections that have a maximum number of items per page.

Parameters:
  • items – The long list of items.
  • items_per_page – The maximum number of items to allow on a page.
  • current_page_number – (See PageIndex)
  • start_page_number – (See PageIndex)
  • max_page_links – (See PageIndex)

AnnualPageIndex

class reahl.web.pager.AnnualPageIndex(annual_item_organiser, current_page_number=1, start_page_number=1, max_page_links=4)

A PageIndex that breaks a list of items up into smaller lists, by arranging all items that have the same year on the same page.

Parameters:
  • annual_item_organiser – An object that implements AnnualItemOrganiserProtocol. Its methods will be called to find the relevent items, or determine what years are applicable.
  • current_page_number – (See PageIndex)
  • start_page_number – (See PageIndex)
  • max_page_links – (See PageIndex)

AnnualItemOrganiserProtocol

class reahl.web.pager.AnnualItemOrganiserProtocol

Manages a list of items, each of which is seen to be for a particular year.

get_years()

Returns a list of integers, each representing a year which is applicable to at least one item in a list of items.

get_items_for_year(year)

Returns a list if items to which year (an integer) is applicable.

Table Of Contents

Previous topic

Module reahl.web.ui

Next topic

Module reahl.web.dhtml