from cStringIO import StringIO from twisted.python import failure import html import resource import linecache import string, re import types def redirectTo(URL, request): request.redirect(URL) return """
Click here. """ % {'url': URL} class Redirect(resource.Resource): def __init__(self, url): resource.Resource.__init__(self) self.url = url def render(self, request): return redirectTo(self.url, request) def htmlrepr(x): return htmlReprTypes.get(type(x), htmlUnknown)(x) def saferepr(x): try: rx = repr(x) except: rx = "'+html.escape(saferepr(x))+'
'
def htmlDict(d):
io = StringIO()
w = io.write
w('Dictionary %d | |
---|---|
%s | \n%s |
List %d | |
---|---|
%s |
'+html.escape(saferepr(i))+'
'
return '''%s instance @ 0x%x |
%s |
%s: %s | ' % (html.escape(str(myFailure.type)), html.escape(str(myFailure.value)))) line = 0 for method, filename, lineno, localVars, globalVars in myFailure.frames: # Cheat to make tracebacks shorter. if filename == '|||||
---|---|---|---|---|---|
%s, line %s in %s
| |||||
| |||||
| ')
w('%s: %s | ' % (html.escape(str(myFailure.type)), html.escape(str(myFailure.value)))) w('