# HG changeset patch # User paulb # Date 1128184043 0 # Node ID 18350128c4570221cd8ca49f0e68be78d8f69a46 # Parent ec1517bd5667299b017324f6027fd7a8c7c4d564 [project @ 2005-10-01 16:27:21 by paulb] Moved the demonstration and made it generic. diff -r ec1517bd5667 -r 18350128c457 examples/BaseHTTPRequestHandler/DemoApp.py --- a/examples/BaseHTTPRequestHandler/DemoApp.py Sat Oct 01 16:27:18 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#!/usr/bin/env python - -""" -A demonstration of XSLTools. This is a quick and dirty combination of an -adapter, employing lots of resources, and the index page resource. -""" - -# Import the things which make the adapter code deploy the application. - -from WebStack.Adapters.BaseHTTPRequestHandler import deploy -from WebStack.Resources.ResourceMap import MapResource - -# Here are all the example applications. - -import Configurator -import Dictionary -from Dictionary.Dict import Dict -import Questionnaire -import PEP241 -import VerySimple - -# A very simple index page. - -from WebStack.Generic import ContentType - -class DemoResource: - def respond(self, trans): - trans.set_content_type(ContentType("text/html")) - trans.get_response_stream().write(""" - - - XSLTools Examples - - -

XSLTools Examples

-

Here are some of the examples supplied with XSLTools:

- -

You can run all of the examples independently, too. See the - examples directory for the code.

- -""") - trans.set_response_code(200) - -# Find out where our example document will be for the dictionary example. - -import os - -cwd = os.getcwd() -parts = os.path.split(cwd) -if parts[-1] == "tools": - parts = parts[:-1] -parts += ("docs", "LICENCE.txt") -doc = os.path.join(*parts) -dict = Dict(doc) - -# Define the resource mapping. - -resource = MapResource({ - "configurator" : Configurator.get_site(), - "dictionary" : Dictionary.get_site(dict), - "questionnaire" : Questionnaire.get_site(), - "pep241" : PEP241.get_site(), - "verysimple" : VerySimple.get_site(), - "" : DemoResource(), - }) - -# Special magic incantation. - -print "Serving..." -deploy(resource, handle_errors=0) - -# vim: tabstop=4 expandtab shiftwidth=4 diff -r ec1517bd5667 -r 18350128c457 examples/Common/DemoApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Common/DemoApp.py Sat Oct 01 16:27:23 2005 +0000 @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +""" +A demonstration of XSLTools. This is a quick and dirty combination of an +adapter, employing lots of resources, and the index page resource. +""" + +# Import the things which publish parts of the application. + +from WebStack.Resources.ResourceMap import MapResource +import os + +# Here are all the example applications. + +import Candidate +import Configurator +import Dictionary +from Dictionary.Dict import Dict +import Questionnaire +import PEP241 +import VerySimple + +# A very simple index page. + +from WebStack.Generic import ContentType + +class DemoResource: + def respond(self, trans): + trans.set_content_type(ContentType("text/html")) + trans.get_response_stream().write(""" + + + XSLTools Examples + + +

XSLTools Examples

+

Here are some of the examples supplied with XSLTools:

+ +

You can run all of the examples independently, too. See the + examples directory for the code.

+ +""") + trans.set_response_code(200) + +# Find out where our example document will be for the dictionary example. + +def get_site(): + + "Define the resource mapping." + + cwd = os.getcwd() + parts = os.path.split(cwd) + if parts[-1] == "tools": + parts = parts[:-1] + parts += ("docs", "LICENCE.txt") + doc = os.path.join(*parts) + dict = Dict(doc) + + resource = MapResource({ + "candidate" : Candidate.get_site(), + "configurator" : Configurator.get_site(), + "dictionary" : Dictionary.get_site(dict), + "questionnaire" : Questionnaire.get_site(), + "pep241" : PEP241.get_site(), + "verysimple" : VerySimple.get_site(), + "" : DemoResource(), + }) + + return resource + +# vim: tabstop=4 expandtab shiftwidth=4