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

Fix #160: document how 'NotFoundError' propagates. #328

Merged
merged 3 commits into from
Nov 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions gcloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ def delete_key(self, key):

:rtype: :class:`gcloud.storage.key.Key`
:returns: The key that was just deleted.
:raises: :class:`gcloud.storage.exceptions.NotFoundError`
:raises: :class:`gcloud.storage.exceptions.NotFoundError` (to suppress
the exception, call ``delete_keys``, passing a no-op
``on_error`` callback, e.g.::

>>> bucket.delete_keys([key], on_error=lambda key: pass)
"""
key = self.new_key(key)
self.connection.api_request(method='DELETE', path=key.path)
Expand All @@ -204,8 +208,12 @@ def delete_keys(self, keys, on_error=None):
:param keys: A list of key names or Key objects to delete.

:type on_error: a callable taking (key)
:param on_error: If not ``None``, called once for each key which
raises a ``NotFoundError``.
:param on_error: If not ``None``, called once for each key raising
:class:`gcloud.storage.exceptions.NotFoundError`;
otherwise, the exception is propagated.

:raises: :class:`gcloud.storage.exceptions.NotFoundError` (if
`on_error` is not passed).
"""
for key in keys:
try:
Expand Down
3 changes: 3 additions & 0 deletions gcloud/storage/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def delete(self):

:rtype: :class:`Key`
:returns: The key that was just deleted.
:raises: :class:`gcloud.storage.exceptions.NotFoundError`
(propagated from
:meth:`gcloud.storage.bucket.Bucket.delete_key`).
"""
return self.bucket.delete_key(self)

Expand Down