pyramid_listing


Namepyramid_listing JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/holgi/pyramid_listing
SummaryPyramid Listing contains pyramid resources and helpers for pagination of result lists
upload_time2018-03-18 10:39:56
maintainer
docs_urlNone
authorHolger Frey
requires_python
licenseBeerware
keywords pyramid list pagination resource
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            =======================
Pyramid List Pagination
=======================

Pyramid List Pagination contains pyramid resources and helpers for pagination
of result lists.

A lot of pyramid_ applications that use a (SQL) database need to list the result
of queries. This result list might get quite long and are split into several
pages. This package is offering some help in this.


Quickstart
----------

Lets assume, that you'd like to start a cheese shop and define a simple
database model in the pyramid application::

    from .meta import Base

    class Cheese(Base):
        id = Column(Integer, primary_key=True)
        name = Column(Text, nullable=False)

To get a result list including pagination, just create a sub-class from
:class:`pyramid_listing.SQLAlchemyListing` and define a ``get_base_query``
method::

    from pyramid_listing import SQLAlchemyListing

    class CheeseList(SQLAlchemyListing):

        def get_base_query(self, request)
            return request.dbsession.query(Cheese)

In a view you could then use this class to autmagically get paged results::

    @view_config(route_name='cheeses')
    def cheese_list_view(request):
        listing = CheeseList(request)
        return {'cheeses': listing.items(), 'pagination': listing.pages}

With this URLs you could access different result pages:

    shows page 3:

    https://example.com/cheeses?p=3

    shows page 1 with 42 items per page:

    https://example.com/cheeses?p=1&n=42


Features
--------

* automatically calculate pagination information like first, next or last page
  from `pyradmid.request.GET` parameters
* loading configuration defaults from .ini files
* easily implement ordering and filtering of results
* helper method for creating `pyradmid.request.GET` parameters for different
  pages
* base class for listings as location aware pyramid resources


Example Project
---------------

To see this in action install the sample project from
https://github.com/holgi/pyramid_listing_example
and take a look at it


Credits
-------

This package was created with Cookiecutter_ and the
`audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _pyramid: https://trypyramid.com


=======
History
=======

0.1.8 (2018-03-18)
------------------
* changed SQLAlchemyListing.pages to a calculated property:

  Just creating a SQLAlchemyListing instance does not automatically trigger
  a database query. It will only execute this first query if pagination
  information is accessed, e.g. in a ordered query.


0.1.7 (2018-03-14)
------------------
* applied filters can now be accessed via ``SQLAlchemyListing.filters``


0.1.6 (2018-03-13)
------------------
* updated documentation setup for readthedocs.org


0.1.5 (2018-03-13)
------------------
* code adjustments after liniting


0.1.4 (2018-03-13)
------------------
* fixed bug where settings as strings were not parsed correctly
* changed default implementation of __getitem__() to use base_query
* changed ordered_query from a calculated property to a real one


0.1.3 (2018-03-12)
------------------

* The classes and the includeme() function are now exposed in the __init__.py
  file


0.1.2 (2018-03-12)
------------------

* The pagination calculation class can now be configured in ``Listing`` and
  ``Resource`` classes. This enables the use of different pagination defaults
  in different lists.


0.1.1 (2018-03-12)
------------------

* Untangled Pagination configuration from includeme() function. Pagination
  (sub-) classes can now be configured via the ``configure()`` method


0.1.0 (2018-03-11)
------------------

* First Working Implementation


0.0.1 (2018-03-08)
------------------

* Starting the project

            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "pyramid list pagination resource", 
    "upload_time": "2018-03-18 10:39:56", 
    "author": "Holger Frey", 
    "home_page": "https://github.com/holgi/pyramid_listing", 
    "github_user": "holgi", 
    "download_url": "https://pypi.python.org/packages/a7/41/49cf41ac4cba7c78028385fa032b385eba6356149df9758a3bb727c61eb0/pyramid_listing-0.1.8.tar.gz", 
    "platform": "", 
    "version": "0.1.8", 
    "cheesecake_documentation_id": null, 
    "description": "=======================\nPyramid List Pagination\n=======================\n\nPyramid List Pagination contains pyramid resources and helpers for pagination\nof result lists.\n\nA lot of pyramid_ applications that use a (SQL) database need to list the result\nof queries. This result list might get quite long and are split into several\npages. This package is offering some help in this.\n\n\nQuickstart\n----------\n\nLets assume, that you'd like to start a cheese shop and define a simple\ndatabase model in the pyramid application::\n\n    from .meta import Base\n\n    class Cheese(Base):\n        id = Column(Integer, primary_key=True)\n        name = Column(Text, nullable=False)\n\nTo get a result list including pagination, just create a sub-class from\n:class:`pyramid_listing.SQLAlchemyListing` and define a ``get_base_query``\nmethod::\n\n    from pyramid_listing import SQLAlchemyListing\n\n    class CheeseList(SQLAlchemyListing):\n\n        def get_base_query(self, request)\n            return request.dbsession.query(Cheese)\n\nIn a view you could then use this class to autmagically get paged results::\n\n    @view_config(route_name='cheeses')\n    def cheese_list_view(request):\n        listing = CheeseList(request)\n        return {'cheeses': listing.items(), 'pagination': listing.pages}\n\nWith this URLs you could access different result pages:\n\n    shows page 3:\n\n    https://example.com/cheeses?p=3\n\n    shows page 1 with 42 items per page:\n\n    https://example.com/cheeses?p=1&n=42\n\n\nFeatures\n--------\n\n* automatically calculate pagination information like first, next or last page\n  from `pyradmid.request.GET` parameters\n* loading configuration defaults from .ini files\n* easily implement ordering and filtering of results\n* helper method for creating `pyradmid.request.GET` parameters for different\n  pages\n* base class for listings as location aware pyramid resources\n\n\nExample Project\n---------------\n\nTo see this in action install the sample project from\nhttps://github.com/holgi/pyramid_listing_example\nand take a look at it\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the\n`audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _pyramid: https://trypyramid.com\n\n\n=======\nHistory\n=======\n\n0.1.8 (2018-03-18)\n------------------\n* changed SQLAlchemyListing.pages to a calculated property:\n\n  Just creating a SQLAlchemyListing instance does not automatically trigger\n  a database query.\u00a0It will only execute this first query if pagination\n  information is accessed, e.g. in a ordered query.\n\n\n0.1.7 (2018-03-14)\n------------------\n* applied filters can now be accessed via ``SQLAlchemyListing.filters``\n\n\n0.1.6 (2018-03-13)\n------------------\n* updated documentation setup for readthedocs.org\n\n\n0.1.5 (2018-03-13)\n------------------\n* code adjustments after liniting\n\n\n0.1.4 (2018-03-13)\n------------------\n* fixed bug where settings as strings were not parsed correctly\n* changed default implementation of __getitem__() to use base_query\n* changed ordered_query from a calculated property to a real one\n\n\n0.1.3 (2018-03-12)\n------------------\n\n* The classes and the includeme() function are now exposed in the __init__.py\n  file\n\n\n0.1.2 (2018-03-12)\n------------------\n\n* The pagination calculation class can now be configured in ``Listing`` and\n  ``Resource`` classes. This enables the use of different pagination defaults\n  in different lists.\n\n\n0.1.1 (2018-03-12)\n------------------\n\n* Untangled Pagination configuration from includeme() function. Pagination\n  (sub-) classes can now be configured via the ``configure()`` method\n\n\n0.1.0 (2018-03-11)\n------------------\n\n* First Working Implementation\n\n\n0.0.1 (2018-03-08)\n------------------\n\n* Starting the project\n", 
    "tox": true, 
    "lcname": "pyramid_listing", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": false, 
    "name": "pyramid_listing", 
    "license": "Beerware", 
    "travis_ci": true, 
    "github_project": "pyramid_listing", 
    "summary": "Pyramid Listing contains pyramid resources and helpers for pagination of result lists", 
    "split_keywords": [
        "pyramid", 
        "list", 
        "pagination", 
        "resource"
    ], 
    "author_email": "mail@holgerfrey.de", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2018-03-18T10:39:59", 
            "comment_text": "", 
            "python_version": "3.6", 
            "url": "https://pypi.python.org/packages/e8/50/3008abc890db822e19f8bf06f0c5461e88264bd1d57a61f809065f0bec0e/pyramid_listing-0.1.8-py2.py3-none-any.whl", 
            "md5_digest": "69b74e7309d24c97d3f7fde6faf0ba67", 
            "downloads": 0, 
            "filename": "pyramid_listing-0.1.8-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "path": "e8/50/3008abc890db822e19f8bf06f0c5461e88264bd1d57a61f809065f0bec0e/pyramid_listing-0.1.8-py2.py3-none-any.whl", 
            "size": 16243
        }, 
        {
            "has_sig": false, 
            "upload_time": "2018-03-18T10:39:56", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/a7/41/49cf41ac4cba7c78028385fa032b385eba6356149df9758a3bb727c61eb0/pyramid_listing-0.1.8.tar.gz", 
            "md5_digest": "837e8fa3559fa83668a35dac69261e14", 
            "downloads": 0, 
            "filename": "pyramid_listing-0.1.8.tar.gz", 
            "packagetype": "sdist", 
            "path": "a7/41/49cf41ac4cba7c78028385fa032b385eba6356149df9758a3bb727c61eb0/pyramid_listing-0.1.8.tar.gz", 
            "size": 35353
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}