aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-18 14:05:59 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-18 14:05:59 -0500
commitcf6ca270ea59b3a2afbdd83e65c8e81760f85633 (patch)
tree5336b21b5b640891b2e9bf0d3714cd32364931a1
parent51f24ff4b3bae358ecd9903537885f4eaf0d1e4b (diff)
downloadbugseverywhere-cf6ca270ea59b3a2afbdd83e65c8e81760f85633.tar.gz
Add ancestors support to HTTP storage
-rw-r--r--libbe/command/serve.py19
-rw-r--r--libbe/storage/http.py7
2 files changed, 25 insertions, 1 deletions
diff --git a/libbe/command/serve.py b/libbe/command/serve.py
index 5dbd2b4..c466900 100644
--- a/libbe/command/serve.py
+++ b/libbe/command/serve.py
@@ -66,7 +66,9 @@ class BERequestHandler (server.BaseHTTPRequestHandler):
data = self.parse_query(query)
try:
- if path == ['children']:
+ if path == ['ancestors']:
+ content,ctype = self.handle_ancestors(data)
+ elif path == ['children']:
content,ctype = self.handle_children(data)
elif len(path) > 1 and path[0] == 'get':
content,ctype = self.handle_get('/'.join(path[1:]), data)
@@ -180,6 +182,21 @@ class BERequestHandler (server.BaseHTTPRequestHandler):
self.send_response(200)
return (None,None)
+ def handle_ancestors(self, data):
+ if not 'id' in data:
+ self.send_error(406, 'Missing query key id')
+ raise _HandlerError()
+ elif data['id'] == 'None':
+ data['id'] = None
+ id = data['id']
+ if not 'revision' in data or data['revision'] == 'None':
+ data['revision'] = None
+ revision = data['revision']
+ content = '\n'.join(self.s.ancestors(id, revision))
+ ctype = 'application/octet-stream'
+ self.send_response(200)
+ return content,ctype
+
def handle_children(self, data):
if not 'id' in data:
self.send_error(406, 'Missing query key id')
diff --git a/libbe/storage/http.py b/libbe/storage/http.py
index 0792b1e..f7b0316 100644
--- a/libbe/storage/http.py
+++ b/libbe/storage/http.py
@@ -142,6 +142,13 @@ class HTTP (base.VersionedStorage):
url, get=False,
data_dict={'id':id, 'recursive':True})
+ def _ancestors(self, id=None, revision=None):
+ url = urlparse.urljoin(self.repo, 'ancestors')
+ page,final_url,info = get_post_url(
+ url, get=True,
+ data_dict={'id':id, 'revision':revision})
+ return page.strip('\n').splitlines()
+
def _children(self, id=None, revision=None):
url = urlparse.urljoin(self.repo, 'children')
page,final_url,info = get_post_url(