Skip to content
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

Implement Iterator.pages and simplify items iteration #2594

Merged
merged 8 commits into from
Oct 25, 2016

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Oct 24, 2016

Fixes #2548. As mentioned in #2529, this came from trying to design for the case that a page of responses came from GAX instead of from an HTTP response.

I have left alone Iterator.next_page_token and Iterator.page_number for now but think the token should be moved to the Page and the page number should just be removed (people can just use enumerate(iterator.pages) if they want the page number).

NOTE: Has #2592 as diffbase.

@dhermes dhermes added api: storage Issues related to the Cloud Storage API. api: bigquery Issues related to the BigQuery API. api: dns Issues related to the Cloud DNS API. api: core api: cloudresourcemanager Issues related to the Resource Manager API. labels Oct 24, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 24, 2016
NOTE: There is a current mismatch between incrementing
Iterator.num_results in Iterator.__iter__ vs. incrementing
it in Iterator.pages (there it won't be incremented, so this
will need to be addressed in a subsequent commit).
Also moving __iter__ functionality into a helper
so that the "started?" check could be done **before**
entering the generator. This is because the "self.pages"
generator wouldn't be entered until an item was consumed
off the items iterator.
Copy link
Contributor

@tseaver tseaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big improvement in the API surface for iterators.

Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.


:rtype: :class:`Iterator`
:returns: Current instance.
:rtype: :class:`~types.GeneratorType`

This comment was marked as spam.

This comment was marked as spam.

@dhermes dhermes merged commit 090c5d5 into googleapis:master Oct 25, 2016
@dhermes dhermes deleted the separate-pages-iter branch October 25, 2016 16:45
dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Oct 25, 2016
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Implement Iterator.pages and simplify items iteration
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. api: cloudresourcemanager Issues related to the Resource Manager API. api: core api: dns Issues related to the Cloud DNS API. api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants