1 #!/usr/bin/env python 2 3 """ 4 A demonstration of XSLTools. This is a quick and dirty combination of an 5 adapter, employing lots of resources, and the index page resource. 6 """ 7 8 # Import the things which make the adapter code deploy the application. 9 10 from WebStack.Adapters.BaseHTTPRequestHandler import deploy 11 from WebStack.Resources.ResourceMap import MapResource 12 13 # Here are all the example applications. 14 15 import Configurator 16 import Questionnaire 17 import PEP241 18 19 # A very simple index page. 20 21 from WebStack.Generic import ContentType 22 23 class DemoResource: 24 def respond(self, trans): 25 trans.set_content_type(ContentType("text/html")) 26 trans.get_response_stream().write(""" 27 <html> 28 <head> 29 <title>XSLTools Examples</title> 30 </head> 31 <body> 32 <h1>XSLTools Examples</h1> 33 <p>Here are some of the examples supplied with XSLTools:</p> 34 <ul> 35 <li><a href="configurator">A Webshop-style system configurator</a></li> 36 <li><a href="questionnaire">A questionnaire generator</a></li> 37 <li><a href="pep241">A Python package repository user interface</a></li> 38 </ul> 39 <p>You can run all of the examples independently, too. See the 40 <code>examples</code> directory for the code.</p> 41 </body> 42 </html>""") 43 trans.set_response_code(200) 44 45 # Define the resource mapping. 46 47 resource = MapResource({ 48 "configurator" : Configurator.get_site(), 49 "questionnaire" : Questionnaire.get_site(), 50 "pep241" : PEP241.get_site(), 51 "" : DemoResource(), 52 }) 53 54 # Special magic incantation. 55 56 print "Serving..." 57 deploy(resource, handle_errors=0) 58 59 # vim: tabstop=4 expandtab shiftwidth=4