[Kimchi-devel] [PATCH] [Wok 5/7] Save log entry IDs for requests that generate tasks
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Sep 1 14:09:32 UTC 2016
On 08/31/2016 06:06 PM, Lucio Correia wrote:
> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
> ---
> src/wok/control/base.py | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/src/wok/control/base.py b/src/wok/control/base.py
> index 213e6b5..06f1f08 100644
> --- a/src/wok/control/base.py
> +++ b/src/wok/control/base.py
> @@ -26,6 +26,7 @@ import urllib2
>
>
> import wok.template
> +from wok.asynctask import save_request_log_id
> from wok.auth import USER_GROUPS, USER_NAME, USER_ROLES
> from wok.control.utils import get_class_name, internal_redirect, model_fn
> from wok.control.utils import parse_request, validate_method
> @@ -162,6 +163,7 @@ class Resource(object):
> self.info['persistent'] is True):
> result = render_fn(self, action_result)
> status = cherrypy.response.status
> +
> return result
> except WokException, e:
> details = e
> @@ -171,7 +173,9 @@ class Resource(object):
> # log request
> code = self.getRequestMessage(method, action_name)
> reqParams = utf8_dict(self.log_args, request)
> - log_request(code, reqParams, details, method, status)
> + log_id = log_request(code, reqParams, details, method, status)
> + if status == 202:
> + save_request_log_id(log_id, action_result['id'])
This should be only on generate_action_handler_task(), right? As this
function is specific to handle Tasks.
>
> wrapper.__name__ = action_name
> wrapper.exposed = True
> @@ -223,7 +227,7 @@ class Resource(object):
> raise
> finally:
> # log request
> - if method not in LOG_DISABLED_METHODS:
> + if method not in LOG_DISABLED_METHODS and status != 202:
Why status 202 has a different behavior?
> code = self.getRequestMessage(method)
> log_request(code, self.log_args, details, method, status)
>
> @@ -307,6 +311,15 @@ class AsyncResource(Resource):
> raise cherrypy.HTTPError(405, e.message)
>
> cherrypy.response.status = 202
> +
> + # log request
> + method = 'DELETE'
> + code = self.getRequestMessage(method)
> + reqParams = utf8_dict(self.log_args)
> + log_id = log_request(code, reqParams, None, method,
> + cherrypy.response.status)
> + save_request_log_id(log_id, task['id'])
> +
Is this result of the "if status != 202" added above?
> return wok.template.render("Task", task)
>
>
> @@ -454,7 +467,7 @@ class Collection(object):
> status = e.status
> raise
> finally:
> - if method not in LOG_DISABLED_METHODS:
> + if method not in LOG_DISABLED_METHODS and status != 202:
> # log request
Same question I did before.
> code = self.getRequestMessage(method)
> reqParams = utf8_dict(self.log_args, params)
> @@ -480,6 +493,15 @@ class AsyncCollection(Collection):
> args = self.model_args + [params]
> task = create(*args)
> cherrypy.response.status = 202
> +
> + # log request
> + method = 'POST'
> + code = self.getRequestMessage(method)
> + reqParams = utf8_dict(self.log_args, params)
> + log_id = log_request(code, reqParams, None, method,
> + cherrypy.response.status)
> + save_request_log_id(log_id, task['id'])
Is this result of the "if status != 202" added above?
Unless to save the log_id to the AsyncTask instance, shouldn't the log
record be the same of the other HTTP return codes?
> +
> return wok.template.render("Task", task)
>
>
More information about the Kimchi-devel
mailing list