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 import VerySimple 19 20 # A very simple index page. 21 22 from WebStack.Generic import ContentType 23 24 class DemoResource: 25 def respond(self, trans): 26 trans.set_content_type(ContentType("text/html")) 27 trans.get_response_stream().write(""" 28 <html> 29 <head> 30 <title>XSLTools Examples</title> 31 </head> 32 <body> 33 <h1>XSLTools Examples</h1> 34 <p>Here are some of the examples supplied with XSLTools:</p> 35 <ul> 36 <li><a href="configurator">A Webshop-style system configurator</a></li> 37 <li><a href="questionnaire">A questionnaire generator</a></li> 38 <li><a href="pep241">A Python package repository user interface</a></li> 39 <li><a href="verysimple">A very simple example</a></li> 40 </ul> 41 <p>You can run all of the examples independently, too. See the 42 <code>examples</code> directory for the code.</p> 43 </body> 44 </html>""") 45 trans.set_response_code(200) 46 47 # Define the resource mapping. 48 49 resource = MapResource({ 50 "configurator" : Configurator.get_site(), 51 "questionnaire" : Questionnaire.get_site(), 52 "pep241" : PEP241.get_site(), 53 "verysimple" : VerySimple.get_site(), 54 "" : DemoResource(), 55 }) 56 57 # Special magic incantation. 58 59 print "Serving..." 60 deploy(resource, handle_errors=0) 61 62 # vim: tabstop=4 expandtab shiftwidth=4