Add enhanced URL building and iteration for APIPaginator.
Review Request #10635 — Created July 19, 2019 and submitted
APIPaginator
is used by hosting services to more easily work with
paginated data from a hosting service, taking care of managing page
data, previous/next URLs, and HTTP requests.This change enhances the support by taking advantage of the new
query=
support for hosting service HTTP requests, allowing callers to more
easily customize their requests in a way that applies to all page
requests, not just the first. This also means the paginator gets to
leverage the cross-Python compatibility already present in the hosting
service's URL building.New iteration helpers have been added that make it trivial to iterate
through pages of information, or all items across pages. This can be
capped to a maximum number of pages, helping ensure that callers don't
iterate forever (for instance, when iterating through the commit tree in
a repository).This does change the result of a single GitHub URL, but it's harmless
and only impacts tests. This is due to the ordering code not kicking in,
since it's a fully manually-built URL. A separate change will
standardize URL building for GitHub.
Unit tests pass.
Tested this with some upcoming code that's taking advantage of the new
URL building and iteration helpers.
- Change Summary:
-
Updated a unit test, which is temporarily impacted by this change.
- Description:
-
APIPaginator
is used by hosting services to more easily work withpaginated data from a hosting service, taking care of managing page data, previous/next URLs, and HTTP requests. This change enhances the support by taking advantage of the new
query=
support for hosting service HTTP requests, allowing callers to more easily customize their requests in a way that applies to all page requests, not just the first. This also means the paginator gets to leverage the cross-Python compatibility already present in the hosting service's URL building. New iteration helpers have been added that make it trivial to iterate
through pages of information, or all items across pages. This can be capped to a maximum number of pages, helping ensure that callers don't iterate forever (for instance, when iterating through the commit tree in a repository). + + This does change the result of a single GitHub URL, but it's harmless
+ and only impacts tests. This is due to the ordering code not kicking in, + since it's a fully manually-built URL. A separate change will + standardize URL building for GitHub. - Commit:
-
0c3e51193e2f3be608a410e5fcbed06667a14c54e80dd5824cff8aabf017f575482c03f069927452