@@ -76,13 +76,12 @@ def get_all_buckets(project=None, connection=None):
7676 :type connection: :class:`gcloud.storage.connection.Connection` or
7777 ``NoneType``
7878 :param connection: Optional. The connection to use when sending requests.
79- If not provided, falls back to default.
79+ If not provided, _BucketIterator() will fall back to
80+ default.
8081
8182 :rtype: iterable of :class:`gcloud.storage.bucket.Bucket` objects.
8283 :returns: All buckets belonging to this project.
8384 """
84- if connection is None :
85- connection = get_default_connection ()
8685 if project is None :
8786 project = get_default_project ()
8887 extra_params = {'project' : project }
@@ -171,6 +170,11 @@ class _BucketIterator(Iterator):
171170 """
172171
173172 def __init__ (self , connection , extra_params = None ):
173+ # If an implicit connection was intended, we pass along `None` to the
174+ # Bucket() constructor as well.
175+ self ._ctor_connection = connection
176+ if connection is None :
177+ connection = get_default_connection ()
174178 super (_BucketIterator , self ).__init__ (connection = connection , path = '/b' ,
175179 extra_params = extra_params )
176180
@@ -182,6 +186,6 @@ def get_items_from_response(self, response):
182186 """
183187 for item in response .get ('items' , []):
184188 name = item .get ('name' )
185- bucket = Bucket (name , connection = self .connection )
189+ bucket = Bucket (name , connection = self ._ctor_connection )
186190 bucket ._properties = item
187191 yield bucket
0 commit comments