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 publish parts of the application. 9 10 from WebStack.Resources.ResourceMap import MapResource 11 import os 12 13 # Here are all the example applications. 14 15 import Candidate 16 import Configurator 17 import Dictionary 18 from Dictionary.Dict import Dict 19 import Questionnaire 20 import PEP241 21 import VerySimple 22 23 # A very simple index page. 24 25 from WebStack.Generic import ContentType 26 27 class DemoResource: 28 def respond(self, trans): 29 trans.set_content_type(ContentType("text/html")) 30 trans.get_response_stream().write(""" 31 <html> 32 <head> 33 <title>XSLTools Examples</title> 34 </head> 35 <body> 36 <h1>XSLTools Examples</h1> 37 <p>Here are some of the examples supplied with XSLTools:</p> 38 <ul> 39 <li><a href="candidate">A job candidate profile editor</a></li> 40 <li><a href="configurator">A Webshop-style system configurator</a></li> 41 <li><a href="dictionary">A simple word lookup interface</a></li> 42 <li><a href="questionnaire">A questionnaire generator</a></li> 43 <li><a href="pep241">A Python package repository user interface</a></li> 44 <li><a href="verysimple">A very simple example</a></li> 45 </ul> 46 <p>You can run all of the examples independently, too. See the 47 <code>examples</code> directory for the code.</p> 48 </body> 49 </html>""") 50 trans.set_response_code(200) 51 52 # Find out where our example document will be for the dictionary example. 53 54 def get_site(): 55 56 "Define the resource mapping." 57 58 cwd = os.getcwd() 59 parts = os.path.split(cwd) 60 if parts[-1] == "tools": 61 parts = parts[:-1] 62 parts += ("docs", "LICENCE.txt") 63 doc = os.path.join(*parts) 64 dict = Dict(doc) 65 66 resource = MapResource({ 67 "candidate" : Candidate.get_site(), 68 "configurator" : Configurator.get_site(), 69 "dictionary" : Dictionary.get_site(dict), 70 "questionnaire" : Questionnaire.get_site(), 71 "pep241" : PEP241.get_site(), 72 "verysimple" : VerySimple.get_site(), 73 "" : DemoResource(), 74 }) 75 76 return resource 77 78 # vim: tabstop=4 expandtab shiftwidth=4