# quixote.demo.pages
#
# Provides miscellaneous pages for the Quixote demo (currently
# just the index page).

__revision__ = "$Id: pages.ptl 21292 2003-04-08 16:48:47Z akuchlin $"


def _q_index [html] (request):
    print "debug message from the index page"
    package_name = str('.').join(__name__.split(str('.'))[:-1])
    module_name = __name__
    module_file = __file__
    """
    <html>
    <head><title>Quixote Demo</title></head>
    <body>
    <h1>Hello, world!</h1>

    <p>(This page is generated by the index function for the
    <code>%(package_name)s</code> package.  This index function is
    actually a PTL template, <code>_q_index()</code>, in the
    <code>%(module_name)s</code> PTL module.  Look in
    <a href="srcdir/pages.ptl">%(module_file)s</a> to
    see the source code for this PTL template.)
    </p>

    <p>To understand what's going on here, be sure to read the
    <code>doc/demo.txt</code> file included with Quixote.</p>

    <p>
    Here are some other features of this demo:
      <ul>
        <li><a href="simple">simple</a>:
            A Python function that generates a very simple document.
        <li><a href="error">error</a>:
            A Python function that raises an exception.
        <li><a href="publish_error">publish_error</a>:
            A Python function that raises
            a <code>PublishError</code> exception.  This exception
            will be caught by a <code>_q_exception_handler</code> method.
        <li><a href="12/">12/</a>:
            A Python object published through <code>_q_lookup()</code>.
        <li><a href="12/factorial">12/factorial</a>:
            A method on a published Python object.
        <li><a href="dumpreq">dumpreq</a>:
            Print out the contents of the HTTPRequest object.
        <li><a href="widgets">widgets</a>:
            Try out the Quixote widget classes.
        <li><a href="form_demo">form demo</a>:
            A Quixote form in action.
        <li><a href="srcdir/">srcdir</a>:
            A static directory published through Quixote.
      </ul>
    </p>
    </body>
    </html>
    """ % vars()

def _q_exception_handler [html] (request, exc):
    """
    <html>
    <head><title>Quixote Demo</title></head>
    <body>
    <h1>Exception Handler</h1>
    <p>A <code>_q_exception_handler</code> method, if present, is
    called when a <code>PublishError</code> exception is raised.  It
    can do whatever it likes to provide a friendly page.
    </p>
    <p>Here's the exception that was raised:<br />
    <code>%s (%s)</code>.</p>
    </body>
    </html>
    """ % (repr(exc), str(exc))

def dumpreq [html] (request):
    """
    <html>
    <head><title>HTTPRequest Object</title></head>
    <body>
    <h1>HTTPRequest Object</h1>
    """
    htmltext(request.dump_html())
    """
    </body>
    </html>
    """

