[PATCH] [Wok] Update AsyncResource class with delete method.

From: Paulo Vital <pvital@linux.vnet.ibm.com> Added the method delete to AysncResource class to be able to execute DELETE requests as AsyncTask. This patch is part of solution to Kimchi issue #817 Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- src/wok/control/base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wok/control/base.py b/src/wok/control/base.py index 25f6522..7aeb844 100644 --- a/src/wok/control/base.py +++ b/src/wok/control/base.py @@ -294,6 +294,22 @@ class AsyncResource(Resource): cherrypy.response.status = 202 return wok.template.render('Task', self.info) + def delete(self): + try: + fn = getattr(self.model, model_fn(self, 'delete')) + task = fn(*self.model_args) + except AttributeError: + e = InvalidOperation('WOKAPI0002E', {'resource': + get_class_name(self)}) + raise cherrypy.HTTPError(405, e.message) + except OperationFailed, e: + raise cherrypy.HTTPError(500, e.message) + except InvalidOperation, e: + raise cherrypy.HTTPError(400, e.message) + + cherrypy.response.status = 202 + return wok.template.render("Task", task) + class Collection(object): """ -- 2.5.5
participants (2)
-
Aline Manera
-
pvital@linux.vnet.ibm.com