chore: remove unneeded statements in wsgi

1. Falcon response's status defaults to 200, no need to set it;
2. Message posting count checking is already covered by input
   validation.

Change-Id: I905dba8bb55e6a4254b2625bb9b71c51496fd2a8
This commit is contained in:
Zhihao Yuan
2013-08-19 11:08:21 -04:00
committed by Gerrit Code Review
parent f5533ed057
commit f9df4da564
6 changed files with 8 additions and 17 deletions

View File

@@ -142,7 +142,7 @@ class ItemResource(object):
resp.content_location = req.relative_uri
resp.body = utils.to_json(meta)
resp.status = falcon.HTTP_200
# status defaults to 200
def on_patch(self, req, resp, project_id, queue_name, claim_id):
LOG.debug(_(u'Claim Item PATCH - claim: %(claim_id)s, '

View File

@@ -149,13 +149,6 @@ class CollectionResource(object):
MESSAGE_POST_SPEC,
doctype=wsgi_utils.JSONArray)
# Verify that at least one message was provided.
# NOTE(kgriffs): This check assumes messages is a
# collection (not a generator).
if not messages:
description = _(u'No messages were provided.')
raise wsgi_exceptions.HTTPBadRequestBody(description)
# Enqueue the messages
partial = False
@@ -195,14 +188,13 @@ class CollectionResource(object):
raise wsgi_exceptions.HTTPServiceUnavailable(description)
# Prepare the response
resp.status = falcon.HTTP_201
ids_value = ','.join(message_ids)
resp.location = req.path + '?ids=' + ids_value
hrefs = [req.path + '/' + id for id in message_ids]
body = {'resources': hrefs, 'partial': partial}
resp.body = utils.to_json(body)
resp.status = falcon.HTTP_201
def on_get(self, req, resp, project_id, queue_name):
LOG.debug(_(u'Messages collection GET - queue: %(queue)s, '
@@ -223,6 +215,7 @@ class CollectionResource(object):
return
resp.body = utils.to_json(response)
# status defaults to 200
def on_delete(self, req, resp, project_id, queue_name):
# NOTE(zyuan): Attempt to delete the whole message collection
@@ -280,7 +273,7 @@ class ItemResource(object):
resp.content_location = req.relative_uri
resp.body = utils.to_json(message)
resp.status = falcon.HTTP_200
# status defaults to 200
def on_delete(self, req, resp, project_id, queue_name, message_id):
LOG.debug(_(u'Messages item DELETE - message: %(message)s, '

View File

@@ -56,7 +56,7 @@ class Resource(object):
resp.content_location = req.path
resp.body = utils.to_json(resp_dict)
resp.status = falcon.HTTP_200
# status defaults to 200
def on_put(self, req, resp, project_id, queue_name):
LOG.debug(_(u'Queue metadata PUT - queue: %(queue)s, '

View File

@@ -139,4 +139,4 @@ class CollectionResource(object):
resp.content_location = req.relative_uri
resp.body = utils.to_json(response_body)
resp.status = falcon.HTTP_200
# status defaults to 200

View File

@@ -51,7 +51,7 @@ class Resource(object):
resp.content_location = req.path
resp.body = utils.to_json(resp_dict)
resp.status = falcon.HTTP_200
# status defaults to 200
except storage_exceptions.DoesNotExist:
raise falcon.HTTPNotFound()

View File

@@ -16,8 +16,6 @@
import json
import falcon
DOC_ROOT = 'http://docs.openstack-marconi.org'
"""Root URL for documents refered to in the home document."""
@@ -156,4 +154,4 @@ class V1Resource(object):
resp.content_type = 'application/json-home'
resp.cache_control = ['max-age=86400']
resp.status = falcon.HTTP_200
# status defaults to 200