1 #!/usr/bin/env python 2 3 # NOTE: Path manipulation requires manual customisation. 4 5 import sys 6 sys.path.append("/home/paulb/Software/Python/WebStack") 7 sys.path.append("/home/paulb/Software/Python/XSLTools") 8 sys.path.append("/home/paulb/Software/Python/XSLTools/examples/Common") 9 sys.path.append("/home/paulb/Software/Python/libxml2dom") 10 11 from WebStack.Adapters import ModPython 12 from WebStack.Resources.ResourceMap import MapResource 13 from WebStack.Resources.Static import DirectoryResource 14 import Configurator 15 import os 16 17 # Get the directory of the application. 18 19 configurator_resource = Configurator.ConfiguratorResource() 20 directory = configurator_resource.resource_dir 21 22 # Make a simple Web site. 23 24 resource = MapResource({ 25 # Static resources: 26 "styles" : DirectoryResource(os.path.join(directory, "styles"), {"css" : "text/css"}), 27 "scripts" : DirectoryResource(os.path.join(directory, "scripts"), {"js" : "text/javascript"}), 28 # Main page: 29 "" : configurator_resource, 30 # Fragments: 31 "cpu" : configurator_resource, 32 "memory" : configurator_resource, 33 "hard-disks" : configurator_resource 34 }) 35 36 # NOTE: Not sure if the resource should be maintained in a resource pool. 37 38 def handler(req): 39 global resource 40 return ModPython.respond(req, resource, handle_errors=0) 41 42 # vim: tabstop=4 expandtab shiftwidth=4