summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwan Mellor <ewan.mellor@citrix.com>2010-07-24 12:29:47 +0100
committerEwan Mellor <ewan.mellor@citrix.com>2010-07-24 12:29:47 +0100
commit7601a422395c4609260f452d09008bdc3fb98201 (patch)
treed6e0fabba341cecbb4bbcf2b5f9e1bbb86df5948
parenteffbd4b4c7077043c0ff2ddcb91607b4e79796f6 (diff)
parentf6ae05f993016f45af2c19718a6e84e50e4a775e (diff)
Merge ~justin-fathomdb/nova/bug607541, since it's impossible to upload
bundles to new buckets without it.
-rw-r--r--nova/objectstore/handler.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py
index c670ee02f..098e7a167 100644
--- a/nova/objectstore/handler.py
+++ b/nova/objectstore/handler.py
@@ -116,7 +116,21 @@ def get_context(request):
logging.debug("Authentication Failure: %s" % ex)
raise exception.NotAuthorized
-class S3(Resource):
+class ErrorHandlingResource(Resource):
+ """Maps exceptions to 404 / 401 codes. Won't work for exceptions thrown after NOT_DONE_YET is returned."""
+ # TODO(unassigned) (calling-all-twisted-experts): This needs to be plugged in to the right place in twisted...
+ # This doesn't look like it's the right place (consider exceptions in getChild; or after NOT_DONE_YET is returned
+ def render(self, request):
+ try:
+ return Resource.render(self, request)
+ except exception.NotFound:
+ request.setResponseCode(404)
+ return ''
+ except exception.NotAuthorized:
+ request.setResponseCode(403)
+ return ''
+
+class S3(ErrorHandlingResource):
"""Implementation of an S3-like storage server based on local files."""
def getChild(self, name, request):
request.context = get_context(request)
@@ -136,7 +150,7 @@ class S3(Resource):
}})
return server.NOT_DONE_YET
-class BucketResource(Resource):
+class BucketResource(ErrorHandlingResource):
def __init__(self, name):
Resource.__init__(self)
self.name = name
@@ -186,7 +200,7 @@ class BucketResource(Resource):
return ''
-class ObjectResource(Resource):
+class ObjectResource(ErrorHandlingResource):
def __init__(self, bucket, name):
Resource.__init__(self)
self.bucket = bucket
@@ -227,7 +241,7 @@ class ObjectResource(Resource):
request.setResponseCode(204)
return ''
-class ImageResource(Resource):
+class ImageResource(ErrorHandlingResource):
isLeaf = True
def getChild(self, name, request):