Merge "Remove recursive imports"

This commit is contained in:
Jenkins 2014-09-08 14:52:16 +00:00 committed by Gerrit Code Review
commit 447960fa1a
4 changed files with 26 additions and 25 deletions

View File

@ -15,18 +15,36 @@
"""wsgi transport helpers.""" """wsgi transport helpers."""
import uuid
import falcon import falcon
import six import six
from zaqar.i18n import _ from zaqar.i18n import _
import zaqar.openstack.common.log as logging import zaqar.openstack.common.log as logging
from zaqar.queues.transport import validation from zaqar.queues.transport import validation
from zaqar.queues.transport.wsgi import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def get_client_uuid(req):
"""Read a required Client-ID from a request.
:param req: A falcon.Request object
:raises: HTTPBadRequest if the Client-ID header is missing or
does not represent a valid UUID
:returns: A UUID object
"""
try:
return uuid.UUID(req.get_header('Client-ID', required=True))
except ValueError:
description = _(u'Malformed hexadecimal UUID.')
raise falcon.HTTPBadRequest('Wrong UUID value', description)
def extract_project_id(req, resp, params): def extract_project_id(req, resp, params):
"""Adds `project_id` to the list of params for all responders """Adds `project_id` to the list of params for all responders
@ -69,7 +87,7 @@ def require_client_id(req, resp, params):
if 'v1.1' in req.path: if 'v1.1' in req.path:
# NOTE(flaper87): `get_client_uuid` already raises 400 # NOTE(flaper87): `get_client_uuid` already raises 400
# it the header is missing. # it the header is missing.
utils.get_client_uuid(req) get_client_uuid(req)
def validate_queue_identification(validate, req, resp, params): def validate_queue_identification(validate, req, resp, params):

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under # License for the specific language governing permissions and limitations under
# the License. # the License.
import uuid
import falcon import falcon
import jsonschema import jsonschema
@ -180,23 +178,6 @@ def get_checked_field(document, name, value_type, default_value):
raise errors.HTTPBadRequestBody(description) raise errors.HTTPBadRequestBody(description)
def get_client_uuid(req):
"""Read a required Client-ID from a request.
:param req: A falcon.Request object
:raises: HTTPBadRequest if the Client-ID header is missing or
does not represent a valid UUID
:returns: A UUID object
"""
try:
return uuid.UUID(req.get_header('Client-ID', required=True))
except ValueError:
description = _(u'Malformed hexadecimal UUID.')
raise errors.HTTPBadRequestAPI(description)
def load(req): def load(req):
"""Reads request body, raising an exception if it is not JSON. """Reads request body, raising an exception if it is not JSON.

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
from zaqar.i18n import _ from zaqar.i18n import _
import zaqar.openstack.common.log as logging import zaqar.openstack.common.log as logging
from zaqar.queues.storage import errors as storage_errors from zaqar.queues.storage import errors as storage_errors
@ -68,7 +69,7 @@ class CollectionResource(object):
return [_format_message(m, base_path) for m in messages] return [_format_message(m, base_path) for m in messages]
def _get(self, req, project_id, queue_name): def _get(self, req, project_id, queue_name):
client_uuid = wsgi_utils.get_client_uuid(req) client_uuid = wsgi_helpers.get_client_uuid(req)
kwargs = {} kwargs = {}
# NOTE(kgriffs): This syntax ensures that # NOTE(kgriffs): This syntax ensures that
@ -130,7 +131,7 @@ class CollectionResource(object):
u'project: %(project)s', u'project: %(project)s',
{'queue': queue_name, 'project': project_id}) {'queue': queue_name, 'project': project_id})
client_uuid = wsgi_utils.get_client_uuid(req) client_uuid = wsgi_helpers.get_client_uuid(req)
try: try:
# Place JSON size restriction before parsing # Place JSON size restriction before parsing

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
from zaqar.i18n import _ from zaqar.i18n import _
import zaqar.openstack.common.log as logging import zaqar.openstack.common.log as logging
from zaqar.queues.storage import errors as storage_errors from zaqar.queues.storage import errors as storage_errors
@ -83,7 +84,7 @@ class CollectionResource(object):
return {'messages': messages} return {'messages': messages}
def _get(self, req, project_id, queue_name): def _get(self, req, project_id, queue_name):
client_uuid = wsgi_utils.get_client_uuid(req) client_uuid = wsgi_helpers.get_client_uuid(req)
kwargs = {} kwargs = {}
# NOTE(kgriffs): This syntax ensures that # NOTE(kgriffs): This syntax ensures that
@ -146,7 +147,7 @@ class CollectionResource(object):
u'project: %(project)s', u'project: %(project)s',
{'queue': queue_name, 'project': project_id}) {'queue': queue_name, 'project': project_id})
client_uuid = wsgi_utils.get_client_uuid(req) client_uuid = wsgi_helpers.get_client_uuid(req)
try: try:
# Place JSON size restriction before parsing # Place JSON size restriction before parsing