Use libbe.util.http.HTTP_USER_ERROR everywhere instead of hardcoding 418
authorW. Trevor King <wking@tremily.us>
Sun, 28 Oct 2012 23:59:41 +0000 (19:59 -0400)
committerW. Trevor King <wking@tremily.us>
Sun, 28 Oct 2012 23:59:41 +0000 (19:59 -0400)
libbe/command/html.py
libbe/command/serve_commands.py
libbe/command/serve_storage.py
libbe/util/wsgi.py

index 8c2ca92ae06ba92bffa2ac313f04857f0957b4ea..2b7dcf8bac27d8c4374565014adedf9dff6a7944 100644 (file)
@@ -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',
index 48d5125de286355d6b5980821d9e850b4a75978e..30b4a6926ed69db54c10209245506aee3a9f407d 100644 (file)
@@ -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
index 9cf2e66f4498d663764b6f1b4286486841ec69b6..086cb84c00868949aa9077f98f03a996ba6957de 100644 (file)
@@ -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),
index d90311cfe1f77c08d6d7d08c747db0f89f88a51a..cd4fbedf145a1d82c43ac7e6466a1cbab5941697 100644 (file)
@@ -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):