Fixed commit handling in commands.serve and storage.http
authorW. Trevor King <wking@drexel.edu>
Fri, 1 Jan 2010 21:48:03 +0000 (16:48 -0500)
committerW. Trevor King <wking@drexel.edu>
Fri, 1 Jan 2010 21:48:03 +0000 (16:48 -0500)
libbe/command/serve.py
libbe/storage/http.py

index 555a7ab4606fd62a8d1418a9acee4b27b1e42d48..e98787f602c30464d86d3c163958cab6b468a314 100644 (file)
@@ -214,15 +214,19 @@ class BERequestHandler (server.BaseHTTPRequestHandler):
             self.send_error(406, 'Missing query key summary')
             return (None,None)
         summary = data['summary']
-        if not body in data or data['body'] == 'None':
+        if not 'body' in data or data['body'] == 'None':
             data['body'] = None
         body = data['body']
-        if not allow_empty in data \
+        if not 'allow_empty' in data \
                 or data['allow_empty'] == 'True':
             allow_empty = True
         else:
             allow_empty = False
-        self.s.commit(summary, body, allow_empty)
+        try:
+            self.s.commit(summary, body, allow_empty)
+        except libbe.storage.EmptyCommit, e:
+            self.send_error(HTTP_USER_ERROR, 'EmptyCommit')
+            return (None,None)
         self.send_response(200)
         return (None,None)
 
index 98a824d53b1d3515ca680028fef37f6a67ca8dba..78fe8939ae2bac2d2aa2c76500f282f47facb23c 100644 (file)
@@ -191,7 +191,7 @@ class HTTP (base.VersionedStorage):
         except InvalidURL, e:
             if not (hasattr(e.error, 'code') and e.error.code in HTTP_VALID):
                 raise
-            if self.e.error.code == HTTP_USER_ERROR:
+            if e.error.code == HTTP_USER_ERROR:
                 raise base.EmptyCommit
             raise base.InvalidID(id)
         return page.rstrip('\n')
@@ -222,7 +222,7 @@ class HTTP (base.VersionedStorage):
         except InvalidURL, e:
             if not (hasattr(e.error, 'code') and e.error.code in HTTP_VALID):
                 raise
-            if self.e.error.code == HTTP_USER_ERROR:
+            if e.error.code == HTTP_USER_ERROR:
                 raise base.InvalidRevision(index)
             raise base.InvalidID(id)
         return page.rstrip('\n')