Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Easy pagination for Pyramid applications

Project Description

Easy pagination for Pyramid applications! It currently has built-in support for paginating:

  • Iterable types (lists, tuples)
  • SQLAlchemy Query objects

But can support pagination over any data type via extensions.

TL;DR

Install with:

$ pip install pyramid_pagination

Use default pagination with:

from pyramid_pagination import paginate

@paginate
def view(request): return range(30)

Then a request without parameters results in:

{
  "result": [0, 1, 2, ... , 22, 23, 24],
  "page": {
    "offset": 0,
    "limit": 25,
    "count": 30,
    "attribute": "result"
  }
}

Paginating with some defaults changed and adding some attribute-based sort methods:

from pyramid_pagination import paginate

@paginate(limit_default=2, comparers=['name', 'value'])
def view(request):
  return [
    dict(name='alph', value=1),
    dict(name='beta', value=2),
    dict(name='zeta', value=3),
    dict(name='alph', value=4),
  ]

Then a request with parameters ?page.offset=1&page.limit=3&page.sort=name-,value results in:

{
  "result": [
    {"name": "beta", "value": 2},
    {"name": "alph", "value": 1},
    {"name": "alph", "value": 4}
  ],
  "page": {
    "offset": 1,
    "limit": 3,
    "count": 4,
    "sort": "name-,value",
    "attribute": "result"
  }
}
Release History

Release History

This version
History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyramid_pagination-0.1.6.tar.gz (17.3 kB) Copy SHA256 Checksum SHA256 Source Apr 12, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting