Merge "Add _ prefix to local variables"
This commit is contained in:
commit
54483cb5c7
@ -33,13 +33,13 @@ class NamedUnicodeStr(six.text_type):
|
|||||||
"""Unicode string look-alike to facilitate overriding __name__."""
|
"""Unicode string look-alike to facilitate overriding __name__."""
|
||||||
|
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
self.value = value
|
self._value = value
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.value
|
return self._value
|
||||||
|
|
||||||
def encode(self, enc):
|
def encode(self, enc):
|
||||||
return self.value.encode(enc)
|
return self._value.encode(enc)
|
||||||
|
|
||||||
def __format__(self, formatstr):
|
def __format__(self, formatstr):
|
||||||
"""Workaround for ddt bug.
|
"""Workaround for ddt bug.
|
||||||
|
@ -44,13 +44,13 @@ class Request(object):
|
|||||||
self._api = None
|
self._api = None
|
||||||
self._api_mod = api
|
self._api_mod = api
|
||||||
|
|
||||||
self.operation = operation
|
self._operation = operation
|
||||||
self.content = content
|
self._content = content
|
||||||
self.params = params or {}
|
self._params = params or {}
|
||||||
self.headers = headers or {}
|
self._headers = headers or {}
|
||||||
|
|
||||||
@decorators.lazy_property()
|
@decorators.lazy_property()
|
||||||
def deserialized_content(self):
|
def deserialized_content(self):
|
||||||
if self.content is not None:
|
if self._content is not None:
|
||||||
return json.loads(self.content)
|
return json.loads(self._content)
|
||||||
return None
|
return None
|
||||||
|
@ -29,9 +29,9 @@ class Response(object):
|
|||||||
:type: dict
|
:type: dict
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('request', 'content', 'headers')
|
__slots__ = ('_request', '_content', '_headers')
|
||||||
|
|
||||||
def __init__(self, request, content, headers=None):
|
def __init__(self, request, content, headers=None):
|
||||||
self.request = request
|
self._request = request
|
||||||
self.content = content
|
self._content = content
|
||||||
self.headers = headers or {}
|
self._headers = headers or {}
|
||||||
|
@ -32,10 +32,10 @@ CLAIM_PATCH_SPEC = (('ttl', int, None),)
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('claim_controller', '_validate')
|
__slots__ = ('_claim_controller', '_validate')
|
||||||
|
|
||||||
def __init__(self, wsgi_conf, validate, claim_controller):
|
def __init__(self, wsgi_conf, validate, claim_controller):
|
||||||
self.claim_controller = claim_controller
|
self._claim_controller = claim_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class CollectionResource(Resource):
|
|||||||
# Claim some messages
|
# Claim some messages
|
||||||
try:
|
try:
|
||||||
self._validate.claim_creation(metadata, limit=limit)
|
self._validate.claim_creation(metadata, limit=limit)
|
||||||
cid, msgs = self.claim_controller.create(
|
cid, msgs = self._claim_controller.create(
|
||||||
queue_name,
|
queue_name,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
@ -92,10 +92,10 @@ class CollectionResource(Resource):
|
|||||||
|
|
||||||
class ItemResource(Resource):
|
class ItemResource(Resource):
|
||||||
|
|
||||||
__slots__ = ('claim_controller', '_validate')
|
__slots__ = ('_claim_controller', '_validate')
|
||||||
|
|
||||||
def __init__(self, wsgi_conf, validate, claim_controller):
|
def __init__(self, wsgi_conf, validate, claim_controller):
|
||||||
self.claim_controller = claim_controller
|
self._claim_controller = claim_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name, claim_id):
|
def on_get(self, req, resp, project_id, queue_name, claim_id):
|
||||||
@ -105,7 +105,7 @@ class ItemResource(Resource):
|
|||||||
'project_id': project_id,
|
'project_id': project_id,
|
||||||
'claim_id': claim_id})
|
'claim_id': claim_id})
|
||||||
try:
|
try:
|
||||||
meta, msgs = self.claim_controller.get(
|
meta, msgs = self._claim_controller.get(
|
||||||
queue_name,
|
queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -149,10 +149,10 @@ class ItemResource(Resource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.claim_updating(metadata)
|
self._validate.claim_updating(metadata)
|
||||||
self.claim_controller.update(queue_name,
|
self._claim_controller.update(queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
resp.status = falcon.HTTP_204
|
resp.status = falcon.HTTP_204
|
||||||
|
|
||||||
@ -176,9 +176,9 @@ class ItemResource(Resource):
|
|||||||
'project_id': project_id,
|
'project_id': project_id,
|
||||||
'claim_id': claim_id})
|
'claim_id': claim_id})
|
||||||
try:
|
try:
|
||||||
self.claim_controller.delete(queue_name,
|
self._claim_controller.delete(queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
resp.status = falcon.HTTP_204
|
resp.status = falcon.HTTP_204
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ import falcon
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('driver',)
|
__slots__ = ('_driver',)
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
self.driver = driver
|
self._driver = driver
|
||||||
|
|
||||||
def on_get(self, req, resp, **kwargs):
|
def on_get(self, req, resp, **kwargs):
|
||||||
resp.status = (falcon.HTTP_204 if self.driver.is_alive()
|
resp.status = (falcon.HTTP_204 if self._driver.is_alive()
|
||||||
else falcon.HTTP_503)
|
else falcon.HTTP_503)
|
||||||
|
|
||||||
def on_head(self, req, resp, **kwargs):
|
def on_head(self, req, resp, **kwargs):
|
||||||
|
@ -32,12 +32,12 @@ MESSAGE_POST_SPEC = (('ttl', int, None), ('body', '*', None))
|
|||||||
|
|
||||||
class CollectionResource(object):
|
class CollectionResource(object):
|
||||||
|
|
||||||
__slots__ = ('message_controller', '_wsgi_conf', '_validate')
|
__slots__ = ('_message_controller', '_wsgi_conf', '_validate')
|
||||||
|
|
||||||
def __init__(self, wsgi_conf, validate, message_controller):
|
def __init__(self, wsgi_conf, validate, message_controller):
|
||||||
self._wsgi_conf = wsgi_conf
|
self._wsgi_conf = wsgi_conf
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Helpers
|
# Helpers
|
||||||
@ -47,7 +47,7 @@ class CollectionResource(object):
|
|||||||
"""Returns one or more messages from the queue by ID."""
|
"""Returns one or more messages from the queue by ID."""
|
||||||
try:
|
try:
|
||||||
self._validate.message_listing(limit=len(ids))
|
self._validate.message_listing(limit=len(ids))
|
||||||
messages = self.message_controller.bulk_get(
|
messages = self._message_controller.bulk_get(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_ids=ids,
|
message_ids=ids,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -81,7 +81,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.message_listing(**kwargs)
|
self._validate.message_listing(**kwargs)
|
||||||
results = self.message_controller.list(
|
results = self._message_controller.list(
|
||||||
queue_name,
|
queue_name,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
client_uuid=client_uuid,
|
client_uuid=client_uuid,
|
||||||
@ -149,7 +149,7 @@ class CollectionResource(object):
|
|||||||
try:
|
try:
|
||||||
self._validate.message_posting(messages)
|
self._validate.message_posting(messages)
|
||||||
|
|
||||||
message_ids = self.message_controller.post(
|
message_ids = self._message_controller.post(
|
||||||
queue_name,
|
queue_name,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
@ -217,7 +217,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.message_listing(limit=len(ids))
|
self._validate.message_listing(limit=len(ids))
|
||||||
self.message_controller.bulk_delete(
|
self._message_controller.bulk_delete(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_ids=ids,
|
message_ids=ids,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -236,10 +236,10 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
class ItemResource(object):
|
class ItemResource(object):
|
||||||
|
|
||||||
__slots__ = ('message_controller')
|
__slots__ = ('_message_controller')
|
||||||
|
|
||||||
def __init__(self, message_controller):
|
def __init__(self, message_controller):
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name, message_id):
|
def on_get(self, req, resp, project_id, queue_name, message_id):
|
||||||
LOG.debug(u'Messages item GET - message: %(message)s, '
|
LOG.debug(u'Messages item GET - message: %(message)s, '
|
||||||
@ -248,7 +248,7 @@ class ItemResource(object):
|
|||||||
'queue': queue_name,
|
'queue': queue_name,
|
||||||
'project': project_id})
|
'project': project_id})
|
||||||
try:
|
try:
|
||||||
message = self.message_controller.get(
|
message = self._message_controller.get(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_id,
|
message_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -279,7 +279,7 @@ class ItemResource(object):
|
|||||||
error_title = _(u'Unable to delete')
|
error_title = _(u'Unable to delete')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.message_controller.delete(
|
self._message_controller.delete(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
|
@ -29,12 +29,12 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
__slots__ = ('_wsgi_conf', '_validate', 'queue_ctrl')
|
__slots__ = ('_wsgi_conf', '_validate', '_queue_ctrl')
|
||||||
|
|
||||||
def __init__(self, _wsgi_conf, validate, queue_controller):
|
def __init__(self, _wsgi_conf, validate, queue_controller):
|
||||||
self._wsgi_conf = _wsgi_conf
|
self._wsgi_conf = _wsgi_conf
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
self.queue_ctrl = queue_controller
|
self._queue_ctrl = queue_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name):
|
def on_get(self, req, resp, project_id, queue_name):
|
||||||
LOG.debug(u'Queue metadata GET - queue: %(queue)s, '
|
LOG.debug(u'Queue metadata GET - queue: %(queue)s, '
|
||||||
@ -42,8 +42,8 @@ class Resource(object):
|
|||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp_dict = self.queue_ctrl.get_metadata(queue_name,
|
resp_dict = self._queue_ctrl.get_metadata(queue_name,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
except storage_errors.DoesNotExist as ex:
|
except storage_errors.DoesNotExist as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
@ -75,9 +75,9 @@ class Resource(object):
|
|||||||
metadata = wsgi_utils.sanitize(document, spec=None)
|
metadata = wsgi_utils.sanitize(document, spec=None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.queue_ctrl.set_metadata(queue_name,
|
self._queue_ctrl.set_metadata(queue_name,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
except validation.ValidationFailed as ex:
|
except validation.ValidationFailed as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
|
@ -28,11 +28,11 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class ItemResource(object):
|
class ItemResource(object):
|
||||||
|
|
||||||
__slots__ = ('queue_controller', 'message_controller')
|
__slots__ = ('_queue_controller', '_message_controller')
|
||||||
|
|
||||||
def __init__(self, queue_controller, message_controller):
|
def __init__(self, queue_controller, message_controller):
|
||||||
self.queue_controller = queue_controller
|
self._queue_controller = queue_controller
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
|
|
||||||
def on_put(self, req, resp, project_id, queue_name):
|
def on_put(self, req, resp, project_id, queue_name):
|
||||||
LOG.debug(u'Queue item PUT - queue: %(queue)s, '
|
LOG.debug(u'Queue item PUT - queue: %(queue)s, '
|
||||||
@ -40,7 +40,7 @@ class ItemResource(object):
|
|||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
created = self.queue_controller.create(
|
created = self._queue_controller.create(
|
||||||
queue_name, project=project_id)
|
queue_name, project=project_id)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@ -56,7 +56,7 @@ class ItemResource(object):
|
|||||||
u'project: %(project)s',
|
u'project: %(project)s',
|
||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
|
|
||||||
if self.queue_controller.exists(queue_name, project=project_id):
|
if self._queue_controller.exists(queue_name, project=project_id):
|
||||||
resp.status = falcon.HTTP_204
|
resp.status = falcon.HTTP_204
|
||||||
else:
|
else:
|
||||||
resp.status = falcon.HTTP_404
|
resp.status = falcon.HTTP_404
|
||||||
@ -70,7 +70,7 @@ class ItemResource(object):
|
|||||||
u'project: %(project)s',
|
u'project: %(project)s',
|
||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
try:
|
try:
|
||||||
self.queue_controller.delete(queue_name, project=project_id)
|
self._queue_controller.delete(queue_name, project=project_id)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
@ -82,10 +82,10 @@ class ItemResource(object):
|
|||||||
|
|
||||||
class CollectionResource(object):
|
class CollectionResource(object):
|
||||||
|
|
||||||
__slots__ = ('queue_controller', '_validate')
|
__slots__ = ('_queue_controller', '_validate')
|
||||||
|
|
||||||
def __init__(self, validate, queue_controller):
|
def __init__(self, validate, queue_controller):
|
||||||
self.queue_controller = queue_controller
|
self._queue_controller = queue_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id):
|
def on_get(self, req, resp, project_id):
|
||||||
@ -102,7 +102,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.queue_listing(**kwargs)
|
self._validate.queue_listing(**kwargs)
|
||||||
results = self.queue_controller.list(project=project_id, **kwargs)
|
results = self._queue_controller.list(project=project_id, **kwargs)
|
||||||
|
|
||||||
except validation.ValidationFailed as ex:
|
except validation.ValidationFailed as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
|
@ -27,15 +27,15 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('queue_ctrl')
|
__slots__ = ('_queue_ctrl')
|
||||||
|
|
||||||
def __init__(self, queue_controller):
|
def __init__(self, queue_controller):
|
||||||
self.queue_ctrl = queue_controller
|
self._queue_ctrl = queue_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name):
|
def on_get(self, req, resp, project_id, queue_name):
|
||||||
try:
|
try:
|
||||||
resp_dict = self.queue_ctrl.stats(queue_name,
|
resp_dict = self._queue_ctrl.stats(queue_name,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
message_stats = resp_dict['messages']
|
message_stats = resp_dict['messages']
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ CLAIM_PATCH_SPEC = (('ttl', int, None),)
|
|||||||
class CollectionResource(object):
|
class CollectionResource(object):
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'claim_controller',
|
'_claim_controller',
|
||||||
'_validate',
|
'_validate',
|
||||||
'_claim_post_spec',
|
'_claim_post_spec',
|
||||||
'_default_meta',
|
'_default_meta',
|
||||||
@ -41,7 +41,7 @@ class CollectionResource(object):
|
|||||||
def __init__(self, wsgi_conf, validate, claim_controller,
|
def __init__(self, wsgi_conf, validate, claim_controller,
|
||||||
default_claim_ttl, default_grace_ttl):
|
default_claim_ttl, default_grace_ttl):
|
||||||
|
|
||||||
self.claim_controller = claim_controller
|
self._claim_controller = claim_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
self._claim_post_spec = (
|
self._claim_post_spec = (
|
||||||
@ -81,7 +81,7 @@ class CollectionResource(object):
|
|||||||
try:
|
try:
|
||||||
self._validate.claim_creation(metadata, limit=limit)
|
self._validate.claim_creation(metadata, limit=limit)
|
||||||
|
|
||||||
cid, msgs = self.claim_controller.create(
|
cid, msgs = self._claim_controller.create(
|
||||||
queue_name,
|
queue_name,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
@ -118,10 +118,10 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
class ItemResource(object):
|
class ItemResource(object):
|
||||||
|
|
||||||
__slots__ = ('claim_controller', '_validate')
|
__slots__ = ('_claim_controller', '_validate')
|
||||||
|
|
||||||
def __init__(self, wsgi_conf, validate, claim_controller):
|
def __init__(self, wsgi_conf, validate, claim_controller):
|
||||||
self.claim_controller = claim_controller
|
self._claim_controller = claim_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name, claim_id):
|
def on_get(self, req, resp, project_id, queue_name, claim_id):
|
||||||
@ -131,7 +131,7 @@ class ItemResource(object):
|
|||||||
'project_id': project_id,
|
'project_id': project_id,
|
||||||
'claim_id': claim_id})
|
'claim_id': claim_id})
|
||||||
try:
|
try:
|
||||||
meta, msgs = self.claim_controller.get(
|
meta, msgs = self._claim_controller.get(
|
||||||
queue_name,
|
queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -175,10 +175,10 @@ class ItemResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.claim_updating(metadata)
|
self._validate.claim_updating(metadata)
|
||||||
self.claim_controller.update(queue_name,
|
self._claim_controller.update(queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
resp.status = falcon.HTTP_204
|
resp.status = falcon.HTTP_204
|
||||||
|
|
||||||
@ -202,9 +202,9 @@ class ItemResource(object):
|
|||||||
'project_id': project_id,
|
'project_id': project_id,
|
||||||
'claim_id': claim_id})
|
'claim_id': claim_id})
|
||||||
try:
|
try:
|
||||||
self.claim_controller.delete(queue_name,
|
self._claim_controller.delete(queue_name,
|
||||||
claim_id=claim_id,
|
claim_id=claim_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
resp.status = falcon.HTTP_204
|
resp.status = falcon.HTTP_204
|
||||||
|
|
||||||
|
@ -23,15 +23,14 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('driver',)
|
__slots__ = ('_driver',)
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
self.driver = driver
|
self._driver = driver
|
||||||
|
|
||||||
def on_get(self, req, resp, **kwargs):
|
def on_get(self, req, resp, **kwargs):
|
||||||
try:
|
try:
|
||||||
resp_dict = self.driver.health()
|
resp_dict = self._driver.health()
|
||||||
|
|
||||||
resp.body = utils.to_json(resp_dict)
|
resp.body = utils.to_json(resp_dict)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
|
@ -31,8 +31,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
class CollectionResource(object):
|
class CollectionResource(object):
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'message_controller',
|
'_message_controller',
|
||||||
'queue_controller',
|
'_queue_controller',
|
||||||
'_wsgi_conf',
|
'_wsgi_conf',
|
||||||
'_validate',
|
'_validate',
|
||||||
'_message_post_spec',
|
'_message_post_spec',
|
||||||
@ -44,8 +44,8 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
self._wsgi_conf = wsgi_conf
|
self._wsgi_conf = wsgi_conf
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
self.queue_controller = queue_controller
|
self._queue_controller = queue_controller
|
||||||
|
|
||||||
self._message_post_spec = (
|
self._message_post_spec = (
|
||||||
('ttl', int, default_message_ttl),
|
('ttl', int, default_message_ttl),
|
||||||
@ -60,7 +60,7 @@ class CollectionResource(object):
|
|||||||
"""Returns one or more messages from the queue by ID."""
|
"""Returns one or more messages from the queue by ID."""
|
||||||
try:
|
try:
|
||||||
self._validate.message_listing(limit=len(ids))
|
self._validate.message_listing(limit=len(ids))
|
||||||
messages = self.message_controller.bulk_get(
|
messages = self._message_controller.bulk_get(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_ids=ids,
|
message_ids=ids,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -96,7 +96,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.message_listing(**kwargs)
|
self._validate.message_listing(**kwargs)
|
||||||
results = self.message_controller.list(
|
results = self._message_controller.list(
|
||||||
queue_name,
|
queue_name,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
client_uuid=client_uuid,
|
client_uuid=client_uuid,
|
||||||
@ -170,10 +170,10 @@ class CollectionResource(object):
|
|||||||
try:
|
try:
|
||||||
self._validate.message_posting(messages)
|
self._validate.message_posting(messages)
|
||||||
|
|
||||||
if not self.queue_controller.exists(queue_name, project_id):
|
if not self._queue_controller.exists(queue_name, project_id):
|
||||||
self.queue_controller.create(queue_name, project=project_id)
|
self._queue_controller.create(queue_name, project=project_id)
|
||||||
|
|
||||||
message_ids = self.message_controller.post(
|
message_ids = self._message_controller.post(
|
||||||
queue_name,
|
queue_name,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
@ -255,7 +255,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
def _delete_messages_by_id(self, queue_name, ids, project_id):
|
def _delete_messages_by_id(self, queue_name, ids, project_id):
|
||||||
try:
|
try:
|
||||||
self.message_controller.bulk_delete(
|
self._message_controller.bulk_delete(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_ids=ids,
|
message_ids=ids,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -273,7 +273,7 @@ class CollectionResource(object):
|
|||||||
u'project: %(project)s',
|
u'project: %(project)s',
|
||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
|
|
||||||
messages = self.message_controller.pop(
|
messages = self._message_controller.pop(
|
||||||
queue_name,
|
queue_name,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
limit=pop_limit)
|
limit=pop_limit)
|
||||||
@ -294,10 +294,10 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
class ItemResource(object):
|
class ItemResource(object):
|
||||||
|
|
||||||
__slots__ = ('message_controller')
|
__slots__ = ('_message_controller')
|
||||||
|
|
||||||
def __init__(self, message_controller):
|
def __init__(self, message_controller):
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name, message_id):
|
def on_get(self, req, resp, project_id, queue_name, message_id):
|
||||||
LOG.debug(u'Messages item GET - message: %(message)s, '
|
LOG.debug(u'Messages item GET - message: %(message)s, '
|
||||||
@ -306,7 +306,7 @@ class ItemResource(object):
|
|||||||
'queue': queue_name,
|
'queue': queue_name,
|
||||||
'project': project_id})
|
'project': project_id})
|
||||||
try:
|
try:
|
||||||
message = self.message_controller.get(
|
message = self._message_controller.get(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_id,
|
message_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
@ -338,7 +338,7 @@ class ItemResource(object):
|
|||||||
error_title = _(u'Unable to delete')
|
error_title = _(u'Unable to delete')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.message_controller.delete(
|
self._message_controller.delete(
|
||||||
queue_name,
|
queue_name,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
|
@ -17,13 +17,13 @@ import falcon
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('driver',)
|
__slots__ = ('_driver',)
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
self.driver = driver
|
self._driver = driver
|
||||||
|
|
||||||
def on_get(self, req, resp, **kwargs):
|
def on_get(self, req, resp, **kwargs):
|
||||||
resp.status = (falcon.HTTP_204 if self.driver.is_alive()
|
resp.status = (falcon.HTTP_204 if self._driver.is_alive()
|
||||||
else falcon.HTTP_503)
|
else falcon.HTTP_503)
|
||||||
|
|
||||||
def on_head(self, req, resp, **kwargs):
|
def on_head(self, req, resp, **kwargs):
|
||||||
|
@ -30,12 +30,12 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class ItemResource(object):
|
class ItemResource(object):
|
||||||
|
|
||||||
__slots__ = ('validate', 'queue_controller', 'message_controller')
|
__slots__ = ('_validate', '_queue_controller', '_message_controller')
|
||||||
|
|
||||||
def __init__(self, validate, queue_controller, message_controller):
|
def __init__(self, validate, queue_controller, message_controller):
|
||||||
self.validate = validate
|
self._validate = validate
|
||||||
self.queue_controller = queue_controller
|
self._queue_controller = queue_controller
|
||||||
self.message_controller = message_controller
|
self._message_controller = message_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name):
|
def on_get(self, req, resp, project_id, queue_name):
|
||||||
LOG.debug(u'Queue metadata GET - queue: %(queue)s, '
|
LOG.debug(u'Queue metadata GET - queue: %(queue)s, '
|
||||||
@ -43,8 +43,8 @@ class ItemResource(object):
|
|||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp_dict = self.queue_controller.get(queue_name,
|
resp_dict = self._queue_controller.get(queue_name,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
except storage_errors.DoesNotExist as ex:
|
except storage_errors.DoesNotExist as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
@ -65,7 +65,7 @@ class ItemResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Place JSON size restriction before parsing
|
# Place JSON size restriction before parsing
|
||||||
self.validate.queue_metadata_length(req.content_length)
|
self._validate.queue_metadata_length(req.content_length)
|
||||||
except validation.ValidationFailed as ex:
|
except validation.ValidationFailed as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
|
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
|
||||||
@ -77,9 +77,9 @@ class ItemResource(object):
|
|||||||
metadata = wsgi_utils.sanitize(document, spec=None)
|
metadata = wsgi_utils.sanitize(document, spec=None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
created = self.queue_controller.create(queue_name,
|
created = self._queue_controller.create(queue_name,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
except storage_errors.FlavorDoesNotExist as ex:
|
except storage_errors.FlavorDoesNotExist as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
@ -98,7 +98,7 @@ class ItemResource(object):
|
|||||||
u'project: %(project)s',
|
u'project: %(project)s',
|
||||||
{'queue': queue_name, 'project': project_id})
|
{'queue': queue_name, 'project': project_id})
|
||||||
try:
|
try:
|
||||||
self.queue_controller.delete(queue_name, project=project_id)
|
self._queue_controller.delete(queue_name, project=project_id)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
@ -110,10 +110,10 @@ class ItemResource(object):
|
|||||||
|
|
||||||
class CollectionResource(object):
|
class CollectionResource(object):
|
||||||
|
|
||||||
__slots__ = ('queue_controller', '_validate')
|
__slots__ = ('_queue_controller', '_validate')
|
||||||
|
|
||||||
def __init__(self, validate, queue_controller):
|
def __init__(self, validate, queue_controller):
|
||||||
self.queue_controller = queue_controller
|
self._queue_controller = queue_controller
|
||||||
self._validate = validate
|
self._validate = validate
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id):
|
def on_get(self, req, resp, project_id):
|
||||||
@ -130,7 +130,7 @@ class CollectionResource(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._validate.queue_listing(**kwargs)
|
self._validate.queue_listing(**kwargs)
|
||||||
results = self.queue_controller.list(project=project_id, **kwargs)
|
results = self._queue_controller.list(project=project_id, **kwargs)
|
||||||
|
|
||||||
except validation.ValidationFailed as ex:
|
except validation.ValidationFailed as ex:
|
||||||
LOG.debug(ex)
|
LOG.debug(ex)
|
||||||
|
@ -27,15 +27,15 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
|
|
||||||
__slots__ = ('queue_ctrl')
|
__slots__ = ('_queue_ctrl')
|
||||||
|
|
||||||
def __init__(self, queue_controller):
|
def __init__(self, queue_controller):
|
||||||
self.queue_ctrl = queue_controller
|
self._queue_ctrl = queue_controller
|
||||||
|
|
||||||
def on_get(self, req, resp, project_id, queue_name):
|
def on_get(self, req, resp, project_id, queue_name):
|
||||||
try:
|
try:
|
||||||
resp_dict = self.queue_ctrl.stats(queue_name,
|
resp_dict = self._queue_ctrl.stats(queue_name,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
|
|
||||||
message_stats = resp_dict['messages']
|
message_stats = resp_dict['messages']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user