Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented May 13, 2015

Both are "sugar" over other methods, but do not allow passing an explicit connection.

In addition, Bucket.__iter__ has scaling issues, which cannot be mitigated using the filtering parameters accepted by Bucket.list_blobs.

Moved to a new PR from #876.

@tseaver tseaver added the api: storage Issues related to the Cloud Storage API. label May 13, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 13, 2015
@dhermes
Copy link
Contributor

dhermes commented May 13, 2015

Big time test failure here. Do you know why?

@tseaver
Copy link
Contributor Author

tseaver commented May 14, 2015

I ran the tests in a different shell, which I closed accidentally before committing. :(

I will rebase / fix after merging #876.

@tseaver
Copy link
Contributor Author

tseaver commented May 14, 2015

@dhermes rebased.

This comment was marked as spam.

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented May 14, 2015

So the reason I asked you to peel this off from #876 was really so we could discuss if this should happen.

I have never really liked the methods, but some may like them. So let's discuss?

@tseaver
Copy link
Contributor Author

tseaver commented May 14, 2015

To clarify what we are discussiing: first, we are removing:

if blob_name in bucket:
   do_something()

which is a syntactic alias for:

blob = Blob(blob_name, bucket)
if blob.exists():
    do_something()

Note that do_something() likely needs to construct the Blob anyway, which makes the second a lot more natural. The second form also allows us to override the connection used by the exists() call, if desired.

Second, we are removing:

for blob in bucket:
    do_something(blob)

which is a syntactic alias for:

for blob in bucket.list_blobs():
    do_something(blob)

Here, the list_blobs() form allows us to override the connection used, if desired, as well as providing filtering parameters to minimize the set of returned blobs: the latter could be crucial for dealing with very large buckets.

@tseaver tseaver added the type: question Request for information or clarification. Not an issue. label May 14, 2015
Both are 'sugar' over other methods, but do not allow passing an explicit
connection.

In addition, 'Bucket.__iter__' has scaling issues, which cannot be mitigated
using the filtering parameters accepted by 'Bucket.list_blobs'.
@dhermes
Copy link
Contributor

dhermes commented May 14, 2015

@jgeewax Are you OK with us removing this?

I am on-board with this change.

@jgeewax
Copy link
Contributor

jgeewax commented May 14, 2015

I'm down with removing the methods, but we need to update the docs in the same PR, right? (https://googlecloudplatform.github.io/gcloud-python/latest/storage-buckets.html refers to for blob in bucket and print 'blob' in bucket.)

@dhermes
Copy link
Contributor

dhermes commented May 14, 2015

+1

@tseaver
Copy link
Contributor Author

tseaver commented May 14, 2015

@jgeewax 3a3edb4 removes the docstring examples which referred to the sugar.

tseaver added a commit that referenced this pull request May 14, 2015
…nd___contains__

Remove 'Bucket.__iter__' and 'Bucket.__contains__'.
@tseaver tseaver merged commit fd73bcf into googleapis:master May 14, 2015
@tseaver tseaver deleted the storage-remove_bucket___iter___and___contains__ branch May 14, 2015 20:11
parthea pushed a commit that referenced this pull request Sep 18, 2025
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants