From 8b2e1ac2ee0245303e5a26f0a1e6ed50b9a903b6 Mon Sep 17 00:00:00 2001 From: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:06:28 -0400 Subject: [PATCH] Squashed commit of the following: commit 172bdfb6c79ed46323287895fb230b95b40332c5 Merge: a594159 affc584 Author: Corinne Lucas <66386084+cnlucas@users.noreply.github.com> Date: Tue Mar 12 09:45:49 2024 -0400 Merge pull request #17 from fecgov/upgrade-python-v3.10 upgrade python v3.10 commit affc584cc3338b257c23a8222e4efeb45bbb3af9 Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Thu Feb 29 11:10:10 2024 -0500 upgrade python v3.10 commit a59415986286fc72f978131c81cc473e470f7fc3 Merge: 30a40d3 70da715 Author: Priya Kasireddy Date: Tue Jan 9 09:23:03 2024 -0500 Merge pull request #15 from fecgov/add-count-type Add is_count_exact to paginator schema commit 70da715b233624484bf95f8e8a0dd63d8b79a7da Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Wed Dec 20 13:44:37 2023 -0500 add count type to paginator schema commit 30a40d31bb71985b41a3dbc03473627520ff59d4 Merge: b6805b7 fc060c9 Author: Priya Kasireddy Date: Mon Jul 31 18:15:54 2023 -0400 Merge pull request #14 from fecgov/upgrade-marshmallow-v3 upgrade marshmallow-v3 commit fc060c95b2e486a20052cb64b1d8580cb08e0b75 Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Mon Jul 31 18:14:08 2023 -0400 upgrade marshmallow-v3 commit b6805b7db8f64a3bbcb952db6a8521308ee52042 Merge: d4d363c 003d6f4 Author: Priya Kasireddy Date: Mon Jul 31 18:11:31 2023 -0400 Merge pull request #13 from fecgov/feature/upgrade-marshmallow-v3 upgrade marshmallow v3 commit 003d6f43ead3791de096b668f51c2f0d620c7dc5 Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Mon Jul 31 18:09:17 2023 -0400 upgrade marshmallow v3 commit d4d363c5d2e13868d7601452edb4efa46851fb83 Merge: 1db0147 a77faac Author: Corinne Lucas <66386084+cnlucas@users.noreply.github.com> Date: Mon Jul 31 17:58:13 2023 -0400 Merge pull request #11 from fecgov/feature/upgrade-marshmallow upgrade to marshmallow v3 commit a77faacc48e73e1dd89b9c2ba8522ce60e423f59 Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Thu Jul 20 14:32:16 2023 -0400 upgrade to marshmallow v3 commit 1db01472e960b655824b2e741ea574c805f3154e Merge: 0f4a530 c963871 Author: tmpayton <121631201+tmpayton@users.noreply.github.com> Date: Mon Jul 17 11:54:45 2023 -0400 Merge pull request #9 from fecgov/revert-8-develop Revert "Marshmallow 3 changes, release branch" commit c9638714089fc6986d4f1ca6a1b64b9cb9b72a6b Author: Corinne Lucas <66386084+cnlucas@users.noreply.github.com> Date: Mon Jul 17 11:51:05 2023 -0400 Revert "Marshmallow 3 changes, release branch" commit 0f4a530f9e8c50c40f375e06f72d74776115b4bf Merge: 3180169 2c9f1c5 Author: Priya Kasireddy Date: Mon Jul 17 09:43:13 2023 -0400 Merge pull request #8 from fecgov/develop Marshmallow 3 changes, release branch commit 3180169f93680ee5e07baf97d28d0913d9a3f036 Merge: 73fe389 b778939 Author: Priya Kasireddy Date: Wed Nov 6 09:55:29 2019 -0500 Merge pull request #4 from fecgov/develop merge develop-->master --- marshmallow_pagination/__init__.py | 2 +- marshmallow_pagination/pages.py | 4 +++- marshmallow_pagination/paginators.py | 7 ++++--- marshmallow_pagination/schemas.py | 5 +++-- setup.py | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/marshmallow_pagination/__init__.py b/marshmallow_pagination/__init__.py index 10939f0..4eb28e3 100644 --- a/marshmallow_pagination/__init__.py +++ b/marshmallow_pagination/__init__.py @@ -1 +1 @@ -__version__ = '0.1.2' +__version__ = '3.0.0' diff --git a/marshmallow_pagination/pages.py b/marshmallow_pagination/pages.py index fac57ac..f4dd651 100644 --- a/marshmallow_pagination/pages.py +++ b/marshmallow_pagination/pages.py @@ -5,7 +5,7 @@ import six -class BasePage(six.with_metaclass(abc.ABCMeta, collections.Sequence)): +class BasePage(six.with_metaclass(abc.ABCMeta, collections.abc.Sequence)): """A page of results. """ def __init__(self, paginator, results): @@ -35,6 +35,7 @@ def info(self): 'count': self.paginator.count, 'pages': self.paginator.pages, 'per_page': self.paginator.per_page, + 'is_count_exact': self.paginator.is_count_exact, } class SeekPage(BasePage): @@ -52,4 +53,5 @@ def info(self): 'pages': self.paginator.pages, 'per_page': self.paginator.per_page, 'last_indexes': self.last_indexes, + 'is_count_exact': self.paginator.is_count_exact, } diff --git a/marshmallow_pagination/paginators.py b/marshmallow_pagination/paginators.py index 9550ecd..ba74a61 100644 --- a/marshmallow_pagination/paginators.py +++ b/marshmallow_pagination/paginators.py @@ -18,8 +18,9 @@ def convert_value(row, attr): class BasePaginator(six.with_metaclass(abc.ABCMeta, object)): - def __init__(self, cursor, per_page, count=None): + def __init__(self, cursor, per_page, is_count_exact=None, count=None): self.cursor = cursor + self.is_count_exact = is_count_exact self.count = count or self._count() self.per_page = per_page or self.count @@ -62,10 +63,10 @@ class SeekPaginator(BasePaginator): """ page_type = pages.SeekPage - def __init__(self, cursor, per_page, index_column, sort_column=None, count=None): + def __init__(self, cursor, per_page, index_column, is_count_exact=None, sort_column=None, count=None): self.index_column = index_column self.sort_column = sort_column - super(SeekPaginator, self).__init__(cursor, per_page, count=count) + super(SeekPaginator, self).__init__(cursor, per_page, is_count_exact=is_count_exact, count=count) def get_page(self, last_index=None, sort_index=None, eager=True): limit = self.per_page diff --git a/marshmallow_pagination/schemas.py b/marshmallow_pagination/schemas.py index 706175c..ae76be6 100644 --- a/marshmallow_pagination/schemas.py +++ b/marshmallow_pagination/schemas.py @@ -4,8 +4,8 @@ import marshmallow as ma class PageSchemaOpts(ma.schema.SchemaOpts): - def __init__(self, meta): - super(PageSchemaOpts, self).__init__(meta) + def __init__(self, meta, ordered=False): + super(PageSchemaOpts, self).__init__(meta, ordered=ordered) self.results_schema_class = getattr(meta, 'results_schema_class', None) self.results_field_name = getattr(meta, 'results_field_name', 'results') self.results_schema_options = getattr(meta, 'results_schema_options', {}) @@ -29,6 +29,7 @@ class BaseInfoSchema(ma.Schema): count = ma.fields.Integer() pages = ma.fields.Integer() per_page = ma.fields.Integer() + is_count_exact = ma.fields.Boolean() class OffsetInfoSchema(BaseInfoSchema): page = ma.fields.Integer() diff --git a/setup.py b/setup.py index 616b87a..08f83ff 100755 --- a/setup.py +++ b/setup.py @@ -6,8 +6,8 @@ REQUIRES = [ - 'marshmallow>=2.0.0b1', - 'marshmallow-sqlalchemy>=0.4.1', + 'marshmallow>=3.0.0', + 'marshmallow-sqlalchemy>=0.16.4', ]