Next / Previous / Contents / TCC Help System / NM Tech homepage

10.6. fullErrorPage()

This function is called when an error has been detected and nothing has been written to sys.stdout. It writes the HTTP headers and then uses the sox module to generate a complete XHTML page.

hist.cgi
# - - -   f u l l E r r o r P a g e

def fullErrorPage(x):
    '''Generate a complete error page displaying exception x, and stop.

      [ x is a lib.ScriptError instance ->
          sys.stdout  +:=  a complete HTML page displaying x
          stop execution ]
    '''
    print "Content-type: text/html"
    print
    s = Sox()
    html = s.start("html")
    head = s.start("head")
    s.leaf("title", "Error")
    head.end()
    body = s.start("body")
    s.leaf("h1", "Error")
    s.leaf("p", str(x))
    body.end()
    html.end()
    sys.exit(1)