# HG changeset patch # User paulb # Date 1121526256 0 # Node ID 8d7591f884510f3a059f1b5d7c7ca343a90453a6 # Parent 438b71968e82b1d53b42954fff4804c0d8b192c5 [project @ 2005-07-16 15:04:16 by paulb] Added mod_python version of the configurator. diff -r 438b71968e82 -r 8d7591f88451 examples/ModPython/ConfiguratorApp/ConfiguratorHandler.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/ModPython/ConfiguratorApp/ConfiguratorHandler.py Sat Jul 16 15:04:16 2005 +0000 @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +# NOTE: Path manipulation requires manual customisation. + +import sys +sys.path.append("/home/paulb/Software/Python/WebStack") +sys.path.append("/home/paulb/Software/Python/XSLTools") +sys.path.append("/home/paulb/Software/Python/XSLTools/examples/Common") +sys.path.append("/home/paulb/Software/Python/libxml2dom") + +from WebStack.Adapters import ModPython +from WebStack.Resources.ResourceMap import MapResource +from WebStack.Resources.Static import DirectoryResource +import Configurator +import os + +# Get the directory of the application. + +configurator_resource = Configurator.ConfiguratorResource() +directory = configurator_resource.resource_dir + +# Make a simple Web site. + +resource = MapResource({ + # Static resources: + "styles" : DirectoryResource(os.path.join(directory, "styles"), {"css" : "text/css"}), + "scripts" : DirectoryResource(os.path.join(directory, "scripts"), {"js" : "text/javascript"}), + # Main page: + "" : configurator_resource, + # Fragments: + "cpu" : configurator_resource, + "memory" : configurator_resource, + "hard-disks" : configurator_resource + }) + +# NOTE: Not sure if the resource should be maintained in a resource pool. + +def handler(req): + global resource + return ModPython.respond(req, resource, handle_errors=0) + +# vim: tabstop=4 expandtab shiftwidth=4