ask/python-github2 — pull request #66 by twidi (2011-10-17 21:04:55+00:00)
Title: Pagination support for lists

For each method asking github for a list, i added a `page` parameter, default to None.

The `get_values` method catch this paramter and then create (or update) a `post_data` paramter sent to `make_request`.

There is no easy way with the current code to know how much pages exist for a given list, so it's up to the user to manage the number of pages to retrieve.

In my code i do something like this:

```python
# store all data from all pages
result = []
# start with page one
page = 1
# we don't know yet the max length of a page
max_length = 0

while True:
# get data for the current page
page_result = github.repos.watching(username, page=page)
# no result ? it's the end
if not page_result:
break
# save the result
result += page_result
# check length of result
l_page = len(page_result)
# if smaller than max, it's the last page
if l_page < max_length:
break
# if bigger, it's the new max
if l_page > max_length:
max_length = l_page
# go next page
page += 1

return result
```