diff options
author | W. Trevor King <wking@drexel.edu> | 2010-01-18 14:22:11 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2010-01-18 14:22:11 -0500 |
commit | d1a6fe5580485e2de745c356dc1d053b0cf233a5 (patch) | |
tree | 1b4f8b1c4960508e807c979388ac2e830c49100a /libbe/command/serve.py | |
parent | cf6ca270ea59b3a2afbdd83e65c8e81760f85633 (diff) | |
download | bugseverywhere-d1a6fe5580485e2de745c356dc1d053b0cf233a5.tar.gz |
Add .changed support to HTTP storage backend.
Also work around urlparse.parse_qs location in Python <= 2.5.
Diffstat (limited to 'libbe/command/serve.py')
-rw-r--r-- | libbe/command/serve.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libbe/command/serve.py b/libbe/command/serve.py index c466900..26be6c1 100644 --- a/libbe/command/serve.py +++ b/libbe/command/serve.py @@ -19,6 +19,13 @@ import posixpath import urllib import urlparse +try: + # Python >= 2.6 + from urlparse import parse_qs +except ImportError: + # Python <= 2.5 + from cgi import parse_qs + import libbe import libbe.command import libbe.command.util @@ -74,6 +81,8 @@ class BERequestHandler (server.BaseHTTPRequestHandler): content,ctype = self.handle_get('/'.join(path[1:]), data) elif path == ['revision-id']: content,ctype = self.handle_revision_id(data) + elif path == ['changed']: + content,ctype = self.handle_changed(data) elif path == ['version']: content,ctype = self.handle_version(data) else: @@ -263,6 +272,16 @@ class BERequestHandler (server.BaseHTTPRequestHandler): self.send_response(200) return content,ctype + def handle_changed(self, data): + if not 'revision' in data or data['revision'] == 'None': + data['revision'] = None + revision = data['revision'] + add,mod,rem = self.s.changed(revision) + content = '\n\n'.join(['\n'.join(p) for p in (add,mod,rem)]) + ctype = 'application/octet-stream' + self.send_response(200) + return content,ctype + def handle_version(self, data): if not 'revision' in data or data['revision'] == 'None': data['revision'] = None @@ -287,7 +306,7 @@ class BERequestHandler (server.BaseHTTPRequestHandler): def parse_query(self, query): if len(query) == 0: return {} - data = urlparse.parse_qs( + data = parse_qs( query, keep_blank_values=True, strict_parsing=True) for k,v in data.items(): if len(v) == 1: |