# HG changeset patch # User paulb # Date 1121546126 0 # Node ID 89febc48a5e324202e4fb8fa1b213ff9dd4716d8 # Parent 21949ec961f350e94b62a0adaba74dff97d9a164 [project @ 2005-07-16 20:35:26 by paulb] Added a demonstration of XSLTools, similar in form to the WebStack demo. diff -r 21949ec961f3 -r 89febc48a5e3 examples/BaseHTTPRequestHandler/DemoApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/BaseHTTPRequestHandler/DemoApp.py Sat Jul 16 20:35:26 2005 +0000 @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +""" +A demonstration of XSLTools. This is a quick and dirty combination of an +adapter, employing lots of resources, and the index page resource. +""" + +# Import the things which make the adapter code deploy the application. + +from WebStack.Adapters.BaseHTTPRequestHandler import deploy +from WebStack.Resources.ResourceMap import MapResource + +# Here are all the example applications. + +import Configurator +import Questionnaire +import PEP241 + +# A very simple index page. + +from WebStack.Generic import ContentType + +class DemoResource: + def respond(self, trans): + trans.set_content_type(ContentType("text/html")) + trans.get_response_stream().write(""" + + + XSLTools Examples + + +

XSLTools Examples

+

Here are some of the examples supplied with XSLTools:

+ +

You can run all of the examples independently, too. See the + examples directory for the code.

+ +""") + trans.set_response_code(200) + +# Define the resource mapping. + +resource = MapResource({ + "configurator" : Configurator.get_site(), + "questionnaire" : Questionnaire.get_site(), + "pep241" : PEP241.get_site(), + "" : DemoResource(), + }) + +# Special magic incantation. + +print "Serving..." +deploy(resource, handle_errors=0) + +# vim: tabstop=4 expandtab shiftwidth=4