diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2014-10-24 18:52:07 +0200 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2014-10-24 18:52:07 +0200 |
commit | dc92c314b74d16afbf48a40edc6d23c0b650094d (patch) | |
tree | 74ebfd2889fe675f3d6267d40f18d53544a33e28 /app/handlers/base.py | |
parent | a4fb3af4f9a3d3fc54bf7627c67e94bc39dc2113 (diff) |
Refactor variable and add new ones.
Change-Id: I5191f25da1aed9c06f1c97c636747b8dcc21c7a7
Diffstat (limited to 'app/handlers/base.py')
-rw-r--r-- | app/handlers/base.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/app/handlers/base.py b/app/handlers/base.py index 67d936b..e4f2082 100644 --- a/app/handlers/base.py +++ b/app/handlers/base.py @@ -52,6 +52,20 @@ from utils.log import get_log from utils.validator import is_valid_json +STATUS_MESSAGES = { + 404: 'Resource not found', + 405: 'Operation not allowed', + 415: ( + 'Please use "%s" as the default media type' % + ACCEPTED_CONTENT_TYPE + ), + 420: 'No JSON data found', + 500: 'Internal database error', + 501: 'Method not implemented', + 506: 'Wrong response type from database' +} + + class BaseHandler(RequestHandler): """The base handler.""" @@ -112,20 +126,7 @@ class BaseHandler(RequestHandler): :type int :return The error message string. """ - status_messages = { - 404: 'Resource not found', - 405: 'Operation not allowed', - 415: ( - 'Please use "%s" as the default media type' % - ACCEPTED_CONTENT_TYPE - ), - 420: 'No JSON data found', - 500: 'Internal database error', - 501: 'Method not implemented', - 506: 'Wrong response type from database' - } - - message = status_messages.get(status_code, None) + message = STATUS_MESSAGES.get(status_code, None) if not message: # If we do not have a custom message, try to see into # the Python lib for the default one or fail safely. |