XSLTools

Changeset

86:81f1b3d65bef
2005-07-14 paulb raw files shortlog changelog graph [project @ 2005-07-14 22:53:21 by paulb] Updated the handlers so that WebStack static resources are used to deal with requests for stylesheets.
examples/BaseHTTPRequestHandler/PEP241App.py (file) examples/BaseHTTPRequestHandler/QuestionnaireApp.py (file)
     1.1 --- a/examples/BaseHTTPRequestHandler/PEP241App.py	Thu Jul 14 22:52:50 2005 +0000
     1.2 +++ b/examples/BaseHTTPRequestHandler/PEP241App.py	Thu Jul 14 22:53:21 2005 +0000
     1.3 @@ -1,11 +1,28 @@
     1.4  #!/usr/bin/env python
     1.5  
     1.6  from WebStack.Adapters.BaseHTTPRequestHandler import deploy
     1.7 +from WebStack.Resources.ResourceMap import MapResource
     1.8 +from WebStack.Resources.Static import DirectoryResource
     1.9  from PEP241 import PEP241Resource
    1.10 +import os
    1.11 +
    1.12 +# Get the directory of the application.
    1.13 +
    1.14 +pep241_resource = PEP241Resource()
    1.15 +directory = pep241_resource.resource_dir
    1.16 +
    1.17 +# Make a simple Web site.
    1.18 +
    1.19 +resource = MapResource({
    1.20 +    # Static resources:
    1.21 +    "styles" : DirectoryResource(os.path.join(directory, "styles"), {"css" : "text/css"}),
    1.22 +    # Main page:
    1.23 +    "" : pep241_resource
    1.24 +    })
    1.25  
    1.26  # Special magic incantation.
    1.27  
    1.28  print "Serving..."
    1.29 -deploy(PEP241Resource(), handle_errors=0)
    1.30 +deploy(resource, handle_errors=0)
    1.31  
    1.32  # vim: tabstop=4 expandtab shiftwidth=4
     2.1 --- a/examples/BaseHTTPRequestHandler/QuestionnaireApp.py	Thu Jul 14 22:52:50 2005 +0000
     2.2 +++ b/examples/BaseHTTPRequestHandler/QuestionnaireApp.py	Thu Jul 14 22:53:21 2005 +0000
     2.3 @@ -1,11 +1,28 @@
     2.4  #!/usr/bin/env python
     2.5  
     2.6  from WebStack.Adapters.BaseHTTPRequestHandler import deploy
     2.7 +from WebStack.Resources.ResourceMap import MapResource
     2.8 +from WebStack.Resources.Static import DirectoryResource
     2.9  from Questionnaire import QuestionnaireEditorResource
    2.10 +import os
    2.11 +
    2.12 +# Get the directory of the application.
    2.13 +
    2.14 +questionnaire_resource = QuestionnaireEditorResource()
    2.15 +directory = questionnaire_resource.resource_dir
    2.16 +
    2.17 +# Make a simple Web site.
    2.18 +
    2.19 +resource = MapResource({
    2.20 +    # Static resources:
    2.21 +    "styles" : DirectoryResource(os.path.join(directory, "styles"), {"css" : "text/css"}),
    2.22 +    # Main page:
    2.23 +    "" : questionnaire_resource
    2.24 +    })
    2.25  
    2.26  # Special magic incantation.
    2.27  
    2.28  print "Serving..."
    2.29 -deploy(QuestionnaireEditorResource(), handle_errors=0)
    2.30 +deploy(resource, handle_errors=0)
    2.31  
    2.32  # vim: tabstop=4 expandtab shiftwidth=4