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)
def paginate(self, filters=None, page=1, per_page=20, **kwargs): qs = self.filter_query(self.query, filters) return paginate(qs, page, per_page, **kwargs)