Use libbe.util.http.HTTP_USER_ERROR everywhere instead of hardcoding 418
[be.git] / libbe / command / serve_storage.py
index 966c9327260991d31c91c897ea7e785b145a3a29..086cb84c00868949aa9077f98f03a996ba6957de 100644 (file)
@@ -1,5 +1,5 @@
 # Copyright (C) 2010-2012 Chris Ball <cjb@laptop.org>
-#                         W. Trevor King <wking@drexel.edu>
+#                         W. Trevor King <wking@tremily.us>
 #
 # This file is part of Bugs Everywhere.
 #
 # You should have received a copy of the GNU General Public License along with
 # Bugs Everywhere.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Define the :class:`Serve` serving BE Storage over HTTP.
+"""Define the :py:class:`Serve` serving BE Storage over HTTP.
 
 See Also
 --------
-:mod:`libbe.storage.http` : the associated client
+:py:mod:`libbe.storage.http` : the associated client
 """
 
 import logging
@@ -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
@@ -71,7 +72,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
     The GET and HEAD requests are identical except that the HEAD
     request omits the actual content of the file.
     """
-    server_version = "BE-server/" + libbe.version.version()
+    server_version = 'BE-storage-server/' + libbe.version.version()
 
     def __init__(self, storage=None, notify=False, **kwargs):
         super(ServerApp, self).__init__(
@@ -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),
@@ -284,8 +284,8 @@ class ServeStorage (libbe.util.wsgi.ServerCommand):
     This allows you to run local `be` commands interfacing with remote
     data, transmitting file reads/writes/etc. over the network.
 
-    :class:`~libbe.command.base.Command` wrapper around
-    :class:`ServerApp`.
+    :py:class:`~libbe.command.base.Command` wrapper around
+    :py:class:`ServerApp`.
     """
 
     name = 'serve-storage'
@@ -307,8 +307,7 @@ And in another terminal (or after backgrounding the server)::
 If you bind your server to a public interface, take a look at the
 ``--read-only`` option or the combined ``--ssl --auth FILE``
 options so other people can't mess with your repository.  If you do use
-authentication, you'll need to send in your username and password with,
-for example::
+authentication, you'll need to send in your username and password::
 
     $ be --repo http://username:password@localhost:8000/ list
 """