XSLTools

Changeset

84:57cf55791e53
2005-07-14 paulb raw files shortlog changelog graph [project @ 2005-07-14 22:25:11 by paulb] Moved stylesheet preparation and usage to the WebStack resource class, introducing method calls in this application.
examples/Common/Configurator/__init__.py (file)
     1.1 --- a/examples/Common/Configurator/__init__.py	Thu Jul 14 22:24:23 2005 +0000
     1.2 +++ b/examples/Common/Configurator/__init__.py	Thu Jul 14 22:25:11 2005 +0000
     1.3 @@ -3,12 +3,9 @@
     1.4  "A WebStack application for a system configurator."
     1.5  
     1.6  import WebStack.Generic
     1.7 -import XSLForms.Output
     1.8 -import XSLForms.Prepare
     1.9  import XSLForms.Utils
    1.10  import XSLForms.Resources
    1.11  import XSLOutput
    1.12 -import libxml2dom
    1.13  import os
    1.14  
    1.15  class ConfiguratorResource(XSLForms.Resources.XSLFormsResource):
    1.16 @@ -17,6 +14,9 @@
    1.17  
    1.18      resource_dir = os.path.join(os.path.split(__file__)[0], "Resources")
    1.19      encoding = "utf-8"
    1.20 +    template_resources = {
    1.21 +        "configuration" : ("config_template.xhtml", "config_output.xsl")
    1.22 +        }
    1.23      in_page_resources = {
    1.24          "/cpu" : ("config_output_cpu.xsl", "cpu-node"),
    1.25          "/memory" : ("config_output_memory.xsl", "memory-node"),
    1.26 @@ -82,26 +82,20 @@
    1.27              # Ensure that an output stylesheet exists.
    1.28  
    1.29              if path_info in self.in_page_resources.keys():
    1.30 -                trans_xsl_filename, trans_xsl_region = self.in_page_resources[path_info]
    1.31 -                template_xml = os.path.join(self.resource_dir, "config_output.xsl")
    1.32 -                trans_xsl = os.path.join(self.resource_dir, trans_xsl_filename)
    1.33 -                XSLForms.Prepare.ensure_stylesheet_fragment(template_xml, trans_xsl, trans_xsl_region)
    1.34 +                trans_xsl = self.prepare_fragment("configuration", path_info)
    1.35                  element_path = parameters.get("element-path", [""])[0]
    1.36                  stylesheet_parameters["element-path"] = element_path
    1.37 -                #print "*", repr(stylesheet_parameters["element-path"])
    1.38              else:
    1.39 -                trans_xsl = os.path.join(self.resource_dir, "config_output.xsl")
    1.40 -                template_xml = os.path.join(self.resource_dir, "config_template.xhtml")
    1.41 -                XSLForms.Prepare.ensure_stylesheet(template_xml, trans_xsl)
    1.42 +                trans_xsl = self.prepare_output("configuration")
    1.43 +
    1.44 +            # Add information essential for in-page requests.
    1.45  
    1.46              stylesheet_parameters["application-url"] = \
    1.47                  "http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query())
    1.48  
    1.49              # Complete the response.
    1.50  
    1.51 -            proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters)
    1.52 -            proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(),
    1.53 -                configuration)
    1.54 +            self.send_output(trans, [trans_xsl], stylesheet_parameters, configuration)
    1.55  
    1.56              #import sys
    1.57              #proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters)