Add support for custom paginated responses in API resources.
Review Request #5895 — Created May 29, 2014 and submitted — Latest diff uploaded
WebAPIResource
now allows subclasses to setpaginated_cls
to a
subclass of aWebAPIResponsePaginated
. This will be used for handling
the pagination of the resource's queryset and for serializing the data.
WebAPIResponsePaginated
has been fully restructured to make its behavior
customizable. Subclasses can override nearly every aspect of it,
including previous/next calculation, URL building, results fetching,
link building, etc. This makes it possible to do such things as paginate
by SHA1, or by page (instead of result item index), or fetch data from
something other than a database-backed queryset.
All Djblets and Review Board unit tests pass.
Implemented a custom paginated response class for use in remote repository
fetching, which needed a different model for pagination (page-based indexes
instead of item-based), and needed to supply slightly different results
(no 'total_results' field). I was able to successfully use it to move back
and forth through results.