@@ -111,9 +111,6 @@ def set_default_connection(project=None, connection=None):
111
111
:type connection: :class:`gcloud.storage.connection.Connection`
112
112
:param connection: A connection provided to be the default.
113
113
"""
114
- if project is None :
115
- project = get_default_project ()
116
-
117
114
connection = connection or get_connection (project )
118
115
_implicit_environ ._DEFAULTS .connection = connection
119
116
@@ -141,7 +138,7 @@ def set_defaults(bucket=None, project=None, connection=None):
141
138
set_default_bucket (bucket = bucket )
142
139
143
140
144
- def get_connection (project ):
141
+ def get_connection (project = None ):
145
142
"""Shortcut method to establish a connection to Cloud Storage.
146
143
147
144
Use this if you are going to access several buckets with the same
@@ -152,12 +149,15 @@ def get_connection(project):
152
149
>>> bucket1 = connection.get_bucket('bucket1')
153
150
>>> bucket2 = connection.get_bucket('bucket2')
154
151
155
- :type project: string
156
- :param project: The name of the project to connect to.
152
+ :type project: string or ``NoneType``
153
+ :param project: Optional. The name of the project to connect to. If not
154
+ included, falls back to default project.
157
155
158
156
:rtype: :class:`gcloud.storage.connection.Connection`
159
157
:returns: A connection defined with the proper credentials.
160
158
"""
159
+ if project is None :
160
+ project = get_default_project ()
161
161
implicit_credentials = credentials .get_credentials ()
162
162
scoped_credentials = implicit_credentials .create_scoped (SCOPE )
163
163
return Connection (project = project , credentials = scoped_credentials )
0 commit comments