# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-paginate VERSION= 0.5.7 KEYWORDS= python VARIANTS= v12 v13 SDESC[v12]= Divides large result sets into pages (3.12) SDESC[v13]= Divides large result sets into pages (3.13) HOMEPAGE= https://github.com/Signum/paginate CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/90/96/04b8e52da071d28f5e21a805b19cb9390aa17a47462ac87f5e2696b9566d DISTFILE[1]= paginate-0.5.7-py2.py3-none-any.whl:main DIST_SUBDIR= python-src DF_INDEX= 1 SPKGS[v12]= single SPKGS[v13]= single OPTIONS_AVAILABLE= PY312 PY313 OPTIONS_STANDARD= none VOPTS[v12]= PY312=ON PY313=OFF VOPTS[v13]= PY312=OFF PY313=ON DISTNAME= paginate-0.5.7.dist-info GENERATED= yes [PY312].USES_ON= python:v12,wheel [PY313].USES_ON= python:v13,wheel [FILE:3580:descriptions/desc.single] What is pagination? --------------------- This module helps dividing large lists of items into pages. The user is shown one page at a time and can navigate to other pages. Imagine you are offering a company phonebook and let the user search the entries. If the search result contains 23 entries but you may want to display no more than 10 entries at once. The first page contains entries 1-10, the second 11-20 and the third 21-23. See the documentation of the "Page" class for more information. How do I use this module? --------------------------- The paginate module contains extensive in-line documentation with examples. Concerning WebHelpers ----------------------- This is a standalone module. Former versions were included in the WebHelpers Python module as webhelpers.paginate and were tightly coupled with the WebHelpers and the Pylons web framework. This version aims to be useful independent of any web framework. Subclassing Page() ------------------ This module supports pagination through list-like objects. To paginate though other types of objects you can subclass the paginate.Page() class and provide a wrapper class that defines how to access elements of that special collection. You can find examples in other paginate_* modules like paginate_sqlalchemy. Basically you would have to provide a class that implements the __init__, __getitem__ and __len__ methods. It is trivial to make pagination for other datastores like Elasticsearch/Solr extending the base class. Example:: class SqlalchemyOrmWrapper(object): """Wrapper class to access elements of a collection.""" def __init__(self, obj): self.obj = obj def __getitem__(self, range): # Return a range of objects of an sqlalchemy.orm.query.Query object return self.obj[range] def __len__(self): # Count the number of objects in an sqlalchemy.orm.query.Query object return self.obj.count() Then you can create your own Page class that uses the above wrapper class:: class SqlalchemyOrmPage(paginate.Page): """A pagination page that deals with SQLAlchemy ORM objects.""" def __init__(self, *args, **kwargs): super(SqlalchemyOrmPage, self).__init__(*args, wrapper_class=SqlalchemyOrmWrapper, **kwargs) As you can see it does not do much. It basically calls paginate.Page.__init__ and adds wrapper_class=SqlalchemyOrmWrapper as an argument. The paginate.Page instance will use that wrapper class to access the elements. Generating HTML code for current page ------------------------------------- Example:: p = paginate.Page([], page=15, items_per_page=15, item_count=1010) # item_count is optional, but we pass a dummy empty resultset for this example pattern = '$link_first $link_previous ~4~ $link_next $link_last (Page $page our of $page_count - total $item_count)' p.pager(pattern, url='http://foo.com?x=$page', dotdot_attr={'x':5}, link_attr={'y':6}, curpage_attr={'z':77}) # *_attr arguments are optional and can be used to attach additional classes/attrs to tags Results in:: '<< < 1 .. 11 12 13 14 15 16 17 18 19 .. 68 > >> (Page 15 our of 68 - total items 1010)' Using url maker to generate links to specific result ranges ----------------------------------------------------------- You can pass `url_maker` Callback to generate the URL of other pages, given its numbers. Must accept one int parameter and return a URI string. Example:: [FILE:125:distinfo] b885e2af73abcf01d9559fd5216b57ef722f8c42affbb63942377668e35c7591 13746 python-src/paginate-0.5.7-py2.py3-none-any.whl