Skip to content

Commit

Permalink
Adding Bucket.path_helper static method for external use.
Browse files Browse the repository at this point in the history
This covers callers which want a bucket path but don't want
to create a full-flegded Bucket object.

See #586 for context.
  • Loading branch information
dhermes committed Feb 3, 2015
1 parent 2538110 commit a59fa43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion gcloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,25 @@ def connection(self):
"""
return self._connection

@staticmethod
def path_helper(bucket_name):
"""Relative URL path for a bucket.
:type bucket_name: string
:param bucket_name: The bucket name in the path.
:rtype: string
:returns: The relative URL path for ``bucket_name``.
"""
return '/b/' + bucket_name

@property
def path(self):
"""The URL path to this bucket."""
if not self.name:
raise ValueError('Cannot determine path without bucket name.')

return '/b/' + self.name
return self.path_helper(self.name)

def get_blob(self, blob):
"""Get a blob object by name.
Expand Down
2 changes: 1 addition & 1 deletion gcloud/storage/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def delete_bucket(self, bucket_name):
:type bucket_name: string
:param bucket_name: The bucket name to delete.
"""
bucket_path = '/b/' + bucket_name
bucket_path = Bucket.path_helper(bucket_name)
self.api_request(method='DELETE', path=bucket_path)

def generate_signed_url(self, resource, expiration,
Expand Down

0 comments on commit a59fa43

Please sign in to comment.