diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2014-07-31 17:15:36 +0200 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2014-07-31 17:15:36 +0200 |
commit | 027608ee954832a7613038c8c3dfffc4d89a3091 (patch) | |
tree | 83dce6ccaae28bdcf2d28490a7029263ff02e2f5 /app/handlers/defconf.py | |
parent | a7ec51dd6fab4a036e7bfa05bf46a858241036a2 (diff) |
Massive refactoring.
* Will break the frontend.
* Rework BaseHandler in order for that to handle all the async
calls setup, and leave the subclasses to implement just the
correct methods.
* TokenHandler is a special case, since we need special token
protection for that.
* Fix db.py so that it returns plaun mongodb objects (Cursor)
and store them as is: they are iteratable.
* Make HandlerResponse the only accepted response type to
create the response that is sent to the clients.
* Fixe, rework and add tests.
Change-Id: Ief7dad65b2801f701e7e5f67b3a360329aca69f6
Diffstat (limited to 'app/handlers/defconf.py')
-rw-r--r-- | app/handlers/defconf.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/handlers/defconf.py b/app/handlers/defconf.py index 2bf9def..8147891 100644 --- a/app/handlers/defconf.py +++ b/app/handlers/defconf.py @@ -15,12 +15,10 @@ """The RequestHandler for /defconfig URLs.""" -import tornado - -from functools import partial from tornado.web import asynchronous from handlers.base import BaseHandler +from handlers.response import HandlerResponse from models import ( ARCHITECTURE_KEY, CREATED_KEY, @@ -59,14 +57,14 @@ class DefConfHandler(BaseHandler): @asynchronous def post(self, *args, **kwargs): """Not implemented.""" - self.write_error(status_code=501) + self.write_error(501) def _delete(self, defconf_id): - self.executor.submit( - partial(delete, self.collection, defconf_id) - ).add_done_callback( - lambda future: - tornado.ioloop.IOLoop.instance().add_callback( - partial(self._create_valid_response, future.result()) - ) - ) + response = HandlerResponse() + response.result = None + + response.status_code = delete(self.collection, defconf_id) + if response.status_code == 200: + response.reason = "Resource %s deleted" % defconf_id + + return response |