Merge "Remove recursive imports"
This commit is contained in:
commit
447960fa1a
@ -15,18 +15,36 @@
|
||||
|
||||
"""wsgi transport helpers."""
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
import six
|
||||
|
||||
from zaqar.i18n import _
|
||||
import zaqar.openstack.common.log as logging
|
||||
from zaqar.queues.transport import validation
|
||||
from zaqar.queues.transport.wsgi import utils
|
||||
|
||||
|
||||
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):
|
||||
"""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:
|
||||
# NOTE(flaper87): `get_client_uuid` already raises 400
|
||||
# it the header is missing.
|
||||
utils.get_client_uuid(req)
|
||||
get_client_uuid(req)
|
||||
|
||||
|
||||
def validate_queue_identification(validate, req, resp, params):
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
import jsonschema
|
||||
|
||||
@ -180,23 +178,6 @@ def get_checked_field(document, name, value_type, default_value):
|
||||
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):
|
||||
"""Reads request body, raising an exception if it is not JSON.
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
import falcon
|
||||
import six
|
||||
|
||||
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
|
||||
from zaqar.i18n import _
|
||||
import zaqar.openstack.common.log as logging
|
||||
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]
|
||||
|
||||
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 = {}
|
||||
|
||||
# NOTE(kgriffs): This syntax ensures that
|
||||
@ -130,7 +131,7 @@ class CollectionResource(object):
|
||||
u'project: %(project)s',
|
||||
{'queue': queue_name, 'project': project_id})
|
||||
|
||||
client_uuid = wsgi_utils.get_client_uuid(req)
|
||||
client_uuid = wsgi_helpers.get_client_uuid(req)
|
||||
|
||||
try:
|
||||
# Place JSON size restriction before parsing
|
||||
|
@ -16,6 +16,7 @@
|
||||
import falcon
|
||||
import six
|
||||
|
||||
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
|
||||
from zaqar.i18n import _
|
||||
import zaqar.openstack.common.log as logging
|
||||
from zaqar.queues.storage import errors as storage_errors
|
||||
@ -83,7 +84,7 @@ class CollectionResource(object):
|
||||
return {'messages': messages}
|
||||
|
||||
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 = {}
|
||||
|
||||
# NOTE(kgriffs): This syntax ensures that
|
||||
@ -146,7 +147,7 @@ class CollectionResource(object):
|
||||
u'project: %(project)s',
|
||||
{'queue': queue_name, 'project': project_id})
|
||||
|
||||
client_uuid = wsgi_utils.get_client_uuid(req)
|
||||
client_uuid = wsgi_helpers.get_client_uuid(req)
|
||||
|
||||
try:
|
||||
# Place JSON size restriction before parsing
|
||||
|
Loading…
Reference in New Issue
Block a user