diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2014-07-29 18:13:40 +0200 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2014-07-29 18:13:40 +0200 |
commit | 199a9f8c13816151ad7f34c94b1ecdfcdda420cc (patch) | |
tree | 2d1032688e64d59b07486de0a0b2f82dfa6c512f /app/handlers/base.py | |
parent | cb3168d84f6e597c9a2c7bec016cf749207c5b3d (diff) |
BaseHandler: Add debug info, fix method.
* Add debug level info from settings.
* Fix GET method.
* Fix error call.
Change-Id: I114455942e6ee4bd345f876eac38c2adf7d13868
Diffstat (limited to 'app/handlers/base.py')
-rw-r--r-- | app/handlers/base.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/handlers/base.py b/app/handlers/base.py index 4553200..3d8043c 100644 --- a/app/handlers/base.py +++ b/app/handlers/base.py @@ -90,7 +90,7 @@ class BaseHandler(RequestHandler): @property def log(self): """The logger of this object.""" - return get_log() + return get_log(debug=self.settings['debug']) def _valid_keys(self, method): """The accepted keys for the valid sent content type. @@ -188,7 +188,6 @@ class BaseHandler(RequestHandler): @protected("POST") @asynchronous def post(self, *args, **kwargs): - valid_request = self._valid_post_request() if valid_request == 200: @@ -198,7 +197,10 @@ class BaseHandler(RequestHandler): if is_valid_json(json_obj, self._valid_keys('POST')): self._post(json_obj) else: - self.send_error(status_code=400) + self.write_error( + status_code=400, + message="Provided JSON is not valid" + ) except ValueError: self.log.error("No JSON data found in the POST request") self.write_error(status_code=420) @@ -252,6 +254,14 @@ class BaseHandler(RequestHandler): @protected("GET") @asynchronous def get(self, *args, **kwargs): + self.execute_get(*args, **kwargs) + + def execute_get(self, *args, **kwargs): + """This is the actual GET operation. + + It is done in this way so that subclasses can implement a different + token authorization if necessary. + """ if kwargs and kwargs.get('id', None): self.executor.submit( partial(self._get_one, kwargs['id']) |