1.1 --- a/examples/BaseHTTPRequestHandler/DemoApp.py Sat Oct 01 16:27:18 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,78 +0,0 @@
1.4 -#!/usr/bin/env python
1.5 -
1.6 -"""
1.7 -A demonstration of XSLTools. This is a quick and dirty combination of an
1.8 -adapter, employing lots of resources, and the index page resource.
1.9 -"""
1.10 -
1.11 -# Import the things which make the adapter code deploy the application.
1.12 -
1.13 -from WebStack.Adapters.BaseHTTPRequestHandler import deploy
1.14 -from WebStack.Resources.ResourceMap import MapResource
1.15 -
1.16 -# Here are all the example applications.
1.17 -
1.18 -import Configurator
1.19 -import Dictionary
1.20 -from Dictionary.Dict import Dict
1.21 -import Questionnaire
1.22 -import PEP241
1.23 -import VerySimple
1.24 -
1.25 -# A very simple index page.
1.26 -
1.27 -from WebStack.Generic import ContentType
1.28 -
1.29 -class DemoResource:
1.30 - def respond(self, trans):
1.31 - trans.set_content_type(ContentType("text/html"))
1.32 - trans.get_response_stream().write("""
1.33 -<html>
1.34 - <head>
1.35 - <title>XSLTools Examples</title>
1.36 - </head>
1.37 - <body>
1.38 - <h1>XSLTools Examples</h1>
1.39 - <p>Here are some of the examples supplied with XSLTools:</p>
1.40 - <ul>
1.41 - <li><a href="configurator">A Webshop-style system configurator</a></li>
1.42 - <li><a href="dictionary">A simple word lookup interface</a></li>
1.43 - <li><a href="questionnaire">A questionnaire generator</a></li>
1.44 - <li><a href="pep241">A Python package repository user interface</a></li>
1.45 - <li><a href="verysimple">A very simple example</a></li>
1.46 - </ul>
1.47 - <p>You can run all of the examples independently, too. See the
1.48 - <code>examples</code> directory for the code.</p>
1.49 - </body>
1.50 -</html>""")
1.51 - trans.set_response_code(200)
1.52 -
1.53 -# Find out where our example document will be for the dictionary example.
1.54 -
1.55 -import os
1.56 -
1.57 -cwd = os.getcwd()
1.58 -parts = os.path.split(cwd)
1.59 -if parts[-1] == "tools":
1.60 - parts = parts[:-1]
1.61 -parts += ("docs", "LICENCE.txt")
1.62 -doc = os.path.join(*parts)
1.63 -dict = Dict(doc)
1.64 -
1.65 -# Define the resource mapping.
1.66 -
1.67 -resource = MapResource({
1.68 - "configurator" : Configurator.get_site(),
1.69 - "dictionary" : Dictionary.get_site(dict),
1.70 - "questionnaire" : Questionnaire.get_site(),
1.71 - "pep241" : PEP241.get_site(),
1.72 - "verysimple" : VerySimple.get_site(),
1.73 - "" : DemoResource(),
1.74 - })
1.75 -
1.76 -# Special magic incantation.
1.77 -
1.78 -print "Serving..."
1.79 -deploy(resource, handle_errors=0)
1.80 -
1.81 -# vim: tabstop=4 expandtab shiftwidth=4