# # # delete "file.psp" # # patch "revision.psp" # from [17ec29c1ac742c32a69f6e71b4e4a0c17faf4e3e] # to [8369faff90b1d2f2e5aafdb0830ee1f618ff1aa0] # # patch "wrapper.py" # from [51003ba637da665d7ab13ca2d44415cf6fdb502a] # to [893dad5aacb5e74f3d4fc56a2f71225752194b70] # ============================================================ --- revision.psp 17ec29c1ac742c32a69f6e71b4e4a0c17faf4e3e +++ revision.psp 8369faff90b1d2f2e5aafdb0830ee1f618ff1aa0 @@ -72,7 +72,7 @@ for id, filename in manifest: %> - <%='%s' % (urllib.quote(id), hq(filename))%> + <%='%s' % (urllib.quote(id), hq(filename))%> <% ============================================================ --- wrapper.py 51003ba637da665d7ab13ca2d44415cf6fdb502a +++ wrapper.py 893dad5aacb5e74f3d4fc56a2f71225752194b70 @@ -1,18 +1,26 @@ - -from mod_python import apache, psp +from mod_python import apache,psp,util +from monotone import Monotone +import config import os import re # paranoid sane_uri_re = re.compile('^\w+$') -def raw_wrapper(req): +def get_file(req): + mt = Monotone(config.monotone, config.dbfile) + form = util.FieldStorage(req) + if not form.has_key('id'): + return apache.HTTP_BAD_REQUEST + id = form['id'] + req.content_type = "text/plain" + req.write(mt.file(id)) req.write("raw file output") return apache.OK handlers = { - 'raw.py' : raw_wrapper + 'getfile.py' : get_file } def handler(req): @@ -22,12 +30,16 @@ if slash <> -1: uri = uri[slash+1:] if handlers.has_key(uri): return handlers[uri](req) - if uri.endswith('.psp') and sane_uri_re.match(uri[:-4]): - req.content_type = "text/html" - template = psp.PSP(req, filename=uri) - template.run() - return apache.OK + try: + if uri.endswith('.psp') and sane_uri_re.match(uri[:-4]): + req.content_type = "text/html" + template = psp.PSP(req, filename=uri) + template.run() + return apache.OK + except ValueError: + return apache.HTTP_NOT_FOUND req.content_type = "text/plain" + req.write("%s" % (os.getcwd())) req.write("URI refers to unknown content handler: %s" % (uri)) return apache.OK