From: W. Trevor King Date: Sun, 28 Oct 2012 23:59:41 +0000 (-0400) Subject: Use libbe.util.http.HTTP_USER_ERROR everywhere instead of hardcoding 418 X-Git-Tag: 1.1.0~10 X-Git-Url: http://git.tremily.us/?p=be.git;a=commitdiff_plain;h=8f1515c8130bff5de7335f648d6bbffc0a4615e5 Use libbe.util.http.HTTP_USER_ERROR everywhere instead of hardcoding 418 --- diff --git a/libbe/command/html.py b/libbe/command/html.py index 8c2ca92..2b7dcf8 100644 --- a/libbe/command/html.py +++ b/libbe/command/html.py @@ -73,7 +73,6 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, self.strip_email = strip_email self.generation_time = generation_time self._refresh = 0 - self.http_user_error = 418 self._load_templates(template_dir=template_dir) self._filters = { 'active': lambda bug: bug.active and bug.severity != 'target', diff --git a/libbe/command/serve_commands.py b/libbe/command/serve_commands.py index 48d5125..30b4a69 100644 --- a/libbe/command/serve_commands.py +++ b/libbe/command/serve_commands.py @@ -77,7 +77,6 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, self.storage = storage self.ui = libbe.command.base.UserInterface() self.notify = notify - self.http_user_error = 418 # handlers def run(self, environ, start_response): @@ -88,13 +87,13 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, name = data['command'] except KeyError: raise libbe.util.wsgi.HandlerError( - self.http_user_error, 'UnknownCommand') + libbe.util.http.HTTP_USER_ERROR, 'UnknownCommand') parameters = data.get('parameters', {}) try: Class = libbe.command.get_command_class(command_name=name) except libbe.command.UnknownCommand, e: raise libbe.util.wsgi.HandlerError( - self.http_user_error, 'UnknownCommand {}'.format(e)) + libbe.util.http.HTTP_USER_ERROR, 'UnknownCommand {}'.format(e)) command = Class(ui=self.ui) self.ui.setup_command(command) arguments = [option.arg for option in command.options diff --git a/libbe/command/serve_storage.py b/libbe/command/serve_storage.py index 9cf2e66..086cb84 100644 --- a/libbe/command/serve_storage.py +++ b/libbe/command/serve_storage.py @@ -29,6 +29,7 @@ import os.path import libbe import libbe.command import libbe.command.util +import libbe.util.http import libbe.util.subproc import libbe.util.wsgi import libbe.version @@ -91,7 +92,6 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, **kwargs) self.storage = storage self.notify = notify - self.http_user_error = 418 # handlers def add(self, environ, start_response): @@ -203,7 +203,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, revision = self.storage.commit(summary, body, allow_empty) except libbe.storage.EmptyCommit, e: raise libbe.util.wsgi.HandlerError( - self.http_user_error, 'EmptyCommit') + libbe.util.http.HTTP_USER_ERROR, 'EmptyCommit') if self.notify: self._notify(environ, 'commit', id, [('allow_empty', allow_empty), ('summary', summary), diff --git a/libbe/util/wsgi.py b/libbe/util/wsgi.py index d90311c..cd4fbed 100644 --- a/libbe/util/wsgi.py +++ b/libbe/util/wsgi.py @@ -60,6 +60,7 @@ except ImportError: import libbe.util.encoding +import libbe.util.http import libbe.util.id import libbe.command import libbe.command.base @@ -307,7 +308,6 @@ class BEExceptionApp (WSGI_Middleware): """ def __init__(self, *args, **kwargs): super(BEExceptionApp, self).__init__(*args, **kwargs) - self.http_user_error = 418 def _call(self, environ, start_response): try: @@ -318,10 +318,10 @@ class BEExceptionApp (WSGI_Middleware): raise libbe.util.wsgi.HandlerError(403, 'Write permission denied') except libbe.storage.InvalidID as e: raise libbe.util.wsgi.HandlerError( - self.http_user_error, 'InvalidID {}'.format(e)) + libbe.util.http.HTTP_USER_ERROR, 'InvalidID {}'.format(e)) except libbe.util.id.NoIDMatches as e: raise libbe.util.wsgi.HandlerError( - self.http_user_error, 'NoIDMatches {}'.format(e)) + libbe.util.http.HTTP_USER_ERROR, 'NoIDMatches {}'.format(e)) class UppercaseHeaderApp (WSGI_Middleware):