# Path: seth/paginator.py
# def paginate(qs, page=1, per_page=20, **kwargs):
#     if page < 1:
#         raise PaginationException(u"Page has to be grater or equal 1")
# 
#     if per_page < 0:
#         raise PaginationException(u"Page has to be grater than 0")
# 
#     total = int(qs.count())
# 
#     if total < (page-1) * per_page:
#         page, per_page = 1, 20
# 
#     items = qs.limit(per_page).offset((page - 1) * per_page).all()
# 
#     if not items and page != 1:
#         return False
# 
#     return Pagination(qs, page, per_page, total, items, **kwargs)


from seth.paginator import paginate
        raise NotImplementedError

    def get_queryset(self, *args, **kwargs):
        raise NotImplementedError

    def filter_queryset(self, qs):
        if self.filter_class:
            filter_instance = self.filter_class(qs)
            return filter_instance.apply(self.request)

        return qs

    def paginate_queryset(self, qs):
        settings = self.request.registry.settings

        page_param = settings.get('pagination.page_param_name', 'page')
        default_page = settings.get('pagination.default_page', 1)
        per_page_param = settings.get('pagination.per_page_param_name', 'per_page')
        default_per_page = settings.get('pagination.default_per_page', 20)

        try:
            page = int(self.request.params.get(page_param, default_page))
        except ValueError:
            page = default_page

        try:
            per_page = int(self.request.params.get(per_page_param, default_per_page))
        except ValueError:
            per_page = default_per_page


# Path: seth/paginator.py
# def paginate(qs, page=1, per_page=20, **kwargs):
#     if page < 1:
#         raise PaginationException(u"Page has to be grater or equal 1")
# 
#     if per_page < 0:
#         raise PaginationException(u"Page has to be grater than 0")
# 
#     total = int(qs.count())
# 
#     if total < (page-1) * per_page:
#         page, per_page = 1, 20
# 
#     items = qs.limit(per_page).offset((page - 1) * per_page).all()
# 
#     if not items and page != 1:
#         return False
# 
#     return Pagination(qs, page, per_page, total, items, **kwargs)


# Path: seth/classy/base.py
from seth.paginator import paginate

        raise NotImplementedError

    def get_queryset(self, *args, **kwargs):
        raise NotImplementedError

    def filter_queryset(self, qs):
        if self.filter_class:
            filter_instance = self.filter_class(qs)
            return filter_instance.apply(self.request)

        return qs

    def paginate_queryset(self, qs):
        settings = self.request.registry.settings

        page_param = settings.get('pagination.page_param_name', 'page')
        default_page = settings.get('pagination.default_page', 1)
        per_page_param = settings.get('pagination.per_page_param_name', 'per_page')
        default_per_page = settings.get('pagination.default_per_page', 20)

        try:
            page = int(self.request.params.get(page_param, default_page))
        except ValueError:
            page = default_page

        try:
            per_page = int(self.request.params.get(per_page_param, default_per_page))
        except ValueError:
            per_page = default_per_page


        return paginate(qs, page, per_page)