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