Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squashed commit of the following: #19

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion marshmallow_pagination/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.2'
__version__ = '3.0.0'
4 changes: 3 additions & 1 deletion marshmallow_pagination/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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,
}
7 changes: 4 additions & 3 deletions marshmallow_pagination/paginators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions marshmallow_pagination/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {})
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


REQUIRES = [
'marshmallow>=2.0.0b1',
'marshmallow-sqlalchemy>=0.4.1',
'marshmallow>=3.0.0',
'marshmallow-sqlalchemy>=0.16.4',
]


Expand Down