1.1 --- a/tools/demo.py Thu Sep 29 14:15:26 2005 +0000
1.2 +++ b/tools/demo.py Thu Sep 29 14:17:04 2005 +0000
1.3 @@ -4,6 +4,23 @@
1.4
1.5 import os, sys
1.6
1.7 +# Find out where WebStack's distribution directory is.
1.8 +
1.9 +program = sys.argv[0]
1.10 +cwd = os.path.split(program)[0]
1.11 +parts = os.path.split(cwd)
1.12 +if parts[-1] == "tools":
1.13 + parts = parts[:-1]
1.14 +base = os.path.join(*parts)
1.15 +
1.16 +# Set up the environment and obtain the demo resource.
1.17 +
1.18 +sys.path.append(base)
1.19 +sys.path.append(os.path.join(base, "examples", "Common"))
1.20 +
1.21 +import DemoApp
1.22 +resource = DemoApp.get_site()
1.23 +
1.24 # Try and open the application in a Web browser.
1.25 # The preferred module is Paul's proposed desktop module - see #1301512 in
1.26 # the Python SourceForge project: http://www.python.org/sf?id=1301512
1.27 @@ -18,24 +35,11 @@
1.28
1.29 desktop.open("http://localhost:8080")
1.30
1.31 -# Find out where WebStack's distribution directory is.
1.32 -
1.33 -cwd = os.getcwd()
1.34 -parts = os.path.split(cwd)
1.35 -if parts[-1] == "tools":
1.36 - parts = parts[:-1]
1.37 -base = os.path.join(*parts)
1.38 -
1.39 -# Set up the environment and run the demo program.
1.40 +# Special magic incantation to start the demo.
1.41
1.42 -pythonpath = os.environ.get("PYTHONPATH")
1.43 -if pythonpath:
1.44 - pythonpath = pythonpath + os.pathsep
1.45 -else:
1.46 - pythonpath = ""
1.47 +from WebStack.Adapters.BaseHTTPRequestHandler import deploy
1.48
1.49 -os.environ["PYTHONPATH"] = "%s%s%s%s" % (pythonpath, base, os.pathsep, os.path.join(base, "examples", "Common"))
1.50 -os.system("%s %s %s" % (sys.executable, os.path.join(base, "examples", "BaseHTTPRequestHandler", "DemoApp.py"),
1.51 - " ".join(sys.argv[1:])))
1.52 +print "Serving..."
1.53 +deploy(resource, handle_errors=0)
1.54
1.55 # vim: tabstop=4 expandtab shiftwidth=4