chipx86 got a fish trophy!
Add initial support for paginators for Hosting Service requests.
Review Request #5885 — Created May 27, 2014 and submitted
We have functions in
HostingService
subclasses that need to deal with
paginated data. Right now, they're all handling it in their own ways,
but as we move to wrapping more of these in the web API, it's helpful to
standardize them.This introduces a set of paginators that can be used and subclassed by
the more specificHostingService
s to provide a standardized API for
pagination of data.
APIPaginator
is designed to perform API requests and handle pagination
through links returned through the payload or headers in some form.
Subclasses are expected to define how API requests are made and parsed.
ProxyPaginator
attaches to another paginator (typically anAPIPaginator
)
and transforms the results. This allows, for instance, a
HostingServiceClient
to return anAPIPaginator
with raw results, and a
HostingService
to wrap it and return structured data derived from those
raw results.
Unit tests passed.
Tested this manually with an accompanying change to GitHub's
get_remote_repositories
. I was able to page back and forth and get the
results. I also testedstart=
andper_page=
with that.
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: reviewboard/hostingsvcs/utils/tests.py reviewboard/hostingsvcs/utils/paginator.py Ignored Files:
- Change Summary:
-
- Improved documentation for APIPaginator, specifically to discuss the expected parameters and access to the HostingServiceClient.
- When computing the URL and attaching query parameters, the parameters are now sorted by key. This helps a lot with unit tests and just keeping requests consistent.
- Fixed a typo.
- Commit:
-
4f83fcb6d0b13d58cc736b4d400bb410e41ecf03b073f1653c3936e033ef7a7c20cc32d22f73eefd
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: reviewboard/hostingsvcs/utils/tests.py reviewboard/hostingsvcs/utils/paginator.py Ignored Files:
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: reviewboard/hostingsvcs/utils/tests.py reviewboard/hostingsvcs/utils/paginator.py Ignored Files:
- Change Summary:
-
Improved a docstring.
- Commit:
-
b073f1653c3936e033ef7a7c20cc32d22f73eefd880ed5a08165ae35395c8e241335466923c3c953
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: reviewboard/hostingsvcs/utils/tests.py reviewboard/hostingsvcs/utils/paginator.py Ignored Files: