# # # add_file "common.py" # content [63e15e4815638f001c26722a4bac42e7690caa63] # # add_file "error.psp" # content [86698bf03d1ef29f0693747d5bb2861969317bf8] # # patch "index.psp" # from [d861d65c4ec05c4a925d3ecc1ebe34dc6aa9ae13] # to [68198f75c1cab5f56db246c51ef178357826b589] # ============================================================ --- common.py 63e15e4815638f001c26722a4bac42e7690caa63 +++ common.py 63e15e4815638f001c26722a4bac42e7690caa63 @@ -0,0 +1,6 @@ + +def html_escape(): + "returns a function stolen from pydoc that can be used to escape HTML" + import pydoc + return pydoc.HTMLRepr().escape + ============================================================ --- error.psp 86698bf03d1ef29f0693747d5bb2861969317bf8 +++ error.psp 86698bf03d1ef29f0693747d5bb2861969317bf8 @@ -0,0 +1,47 @@ + + +Error + + + +<% + +import common +hq = common.html_escape() + +# now; if they raised a plain Exception() then we shall display a simple error +# message without a traceback: this is an intentionally raised Exception rather than +# a program error +e_type, e_value, e_traceback = sys.exc_info() +if (str(e_type) == "exceptions.Exception"): +%> + +

+An error has occurred: +

+ +

+<%= hq(str(e_value)) %> +

+ +

+If necessary, please report this error to the system administrator. You may wish to return +to the index page. +

+ +<% +else: +%> +

Exception:

+ +

+<% + import traceback + mesg = traceback.format_exception(e_type, e_value, e_traceback) + mesg = map(hq, mesg) + req.write('

' + '
'.join(mesg) + '
') +%> +

+ + + ============================================================ --- index.psp d861d65c4ec05c4a925d3ecc1ebe34dc6aa9ae13 +++ index.psp 68198f75c1cab5f56db246c51ef178357826b589 @@ -6,13 +6,23 @@ reload(monotone) from monotone import Monotone +hq = common.html_escape() mt = Monotone(config.monotone, config.dbfile) -req.write("Branches: %s" % (str(mt.get_branches()))) + +psp.set_error_page("error.psp") + %> -ViewMTN +

ViewMTN :: Index

+

Branches

+ <% +for branch in mt.get_branches(): + req.write('%s' % ( + +<% + %>