Skip to content

Pagination example #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ericfrederich opened this issue Sep 7, 2017 · 1 comment
Closed

Pagination example #304

ericfrederich opened this issue Sep 7, 2017 · 1 comment

Comments

@ericfrederich
Copy link
Contributor

Docs don't give an example on how to fully use pagination.

It only has an example of doing a listing with page=1, per_page=10

Is there a way, for example, to know ahead of time how many pages there will be?

For example I'm calling gl.project_issues.list(project_id=project.id, per_page=10, page=n)
By incrementing n beyond the actual number of pages I see that I don't get an exception of any kind, instead just empty lists.

I only found that out by digging into it. I don't see it documented anywhere.

@gpocentek
Copy link
Contributor

Hi @ericfrederich,

I agree with you, the documentation could be improved.

There are some changes regarding pagination in the master, for the v4 API: you can get more information about the number of pages, last page and number of items with the GitlabList object (https://github.com/python-gitlab/python-gitlab/blob/master/gitlab/__init__.py#L829).

There are still some improvements to be made in the RESTObjectList object (the "public" object returned by list() methods) but the basics are in place.

http://python-gitlab.readthedocs.io/en/master/switching-to-v4.html#changes-between-v3-and-v4-api documents the list() method changes for v4.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants