# HG changeset patch # User paulb # Date 1114896210 0 # Node ID c04598c3937a744e54b9d7ab15ea60351022673d # Parent dc3782d8019d3a2800fa35e44f80de9bbecc17ed [project @ 2005-04-30 21:23:23 by paulb] Added a simple demonstration application and launcher program. diff -r dc3782d8019d -r c04598c3937a README.txt --- a/README.txt Sat Apr 30 20:44:03 2005 +0000 +++ b/README.txt Sat Apr 30 21:23:30 2005 +0000 @@ -8,6 +8,13 @@ application in a different environment later on without having to go back and rewrite substantial parts of the application. +Quick Start +----------- + +Try running the demo: + +python tools/demo.py + Framework Support ----------------- @@ -22,7 +29,7 @@ Tested Frameworks Release Information ----------------- ------------------- -BaseHTTPRequestHandler Python 2.2.2, Python 2.3.3 +BaseHTTPRequestHandler Python 2.2.2, Python 2.3.3, Python 2.4.1 CGI Apache 2.0.44 Jython/Java Servlet API Jython 2.1, Java JDK 1.3.1_02, Tomcat 4.1.27 (Servlet 2.3) mod_python 3.0.3 (3.1.3 for framework cookie and session support) diff -r dc3782d8019d -r c04598c3937a examples/BaseHTTPRequestHandler/DemoApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/BaseHTTPRequestHandler/DemoApp.py Sat Apr 30 21:23:30 2005 +0000 @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +""" +A demonstration of WebStack. 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 test resources. + +from Cookies import CookiesResource +from Form import FormResource +from Sessions import SessionsResource +from Simple import SimpleResource +from Unicode import UnicodeResource +from VerySimple import VerySimpleResource + +# 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(""" + + + WebStack Examples + + +

WebStack Examples

+

Here are some of the examples supplied with WebStack:

+ +

You can run all of the examples independently - see the documentation in + the docs directory, especially the subdirectories for each + of the server environments or frameworks, for details of how this is + done.

+ +""") + trans.set_response_code(200) + +# Define the resource mapping. + +resource = MapResource({ + "cookies" : CookiesResource(), + "form" : FormResource(), + "sessions" : SessionsResource(), + "simple" : SimpleResource(), + "unicode" : UnicodeResource(), + "verysimple" : VerySimpleResource(), + "" : DemoResource(), + }) + +# Special magic incantation. + +print "Serving..." +deploy(resource, handle_errors=0) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r dc3782d8019d -r c04598c3937a tools/demo.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/demo.py Sat Apr 30 21:23:30 2005 +0000 @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +"Start the demonstration program." + +import os, sys + +# Find out where WebStack's distribution directory is. + +cwd = os.getcwd() +parts = os.path.split(cwd) +if parts[-1] == "tools": + parts = parts[:-1] +base = os.path.join(*parts) + +# Set up the environment and run the demo program. + +os.environ["PYTHONPATH"] = "%s:%s" % (base, os.path.join(base, "examples", "Common")) +os.system("%s %s" % (sys.executable, os.path.join(base, "examples", "BaseHTTPRequestHandler", "DemoApp.py"))) + +# vim: tabstop=4 expandtab shiftwidth=4