# HG changeset patch # User paulb # Date 1121379911 0 # Node ID 57cf55791e531a9d44de1bdea11bf1f2a8d41648 # Parent 32a48ea3b9561ab3b232e0f909114d9f2e9cc847 [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. diff -r 32a48ea3b956 -r 57cf55791e53 examples/Common/Configurator/__init__.py --- a/examples/Common/Configurator/__init__.py Thu Jul 14 22:24:23 2005 +0000 +++ b/examples/Common/Configurator/__init__.py Thu Jul 14 22:25:11 2005 +0000 @@ -3,12 +3,9 @@ "A WebStack application for a system configurator." import WebStack.Generic -import XSLForms.Output -import XSLForms.Prepare import XSLForms.Utils import XSLForms.Resources import XSLOutput -import libxml2dom import os class ConfiguratorResource(XSLForms.Resources.XSLFormsResource): @@ -17,6 +14,9 @@ resource_dir = os.path.join(os.path.split(__file__)[0], "Resources") encoding = "utf-8" + template_resources = { + "configuration" : ("config_template.xhtml", "config_output.xsl") + } in_page_resources = { "/cpu" : ("config_output_cpu.xsl", "cpu-node"), "/memory" : ("config_output_memory.xsl", "memory-node"), @@ -82,26 +82,20 @@ # Ensure that an output stylesheet exists. if path_info in self.in_page_resources.keys(): - trans_xsl_filename, trans_xsl_region = self.in_page_resources[path_info] - template_xml = os.path.join(self.resource_dir, "config_output.xsl") - trans_xsl = os.path.join(self.resource_dir, trans_xsl_filename) - XSLForms.Prepare.ensure_stylesheet_fragment(template_xml, trans_xsl, trans_xsl_region) + trans_xsl = self.prepare_fragment("configuration", path_info) element_path = parameters.get("element-path", [""])[0] stylesheet_parameters["element-path"] = element_path - #print "*", repr(stylesheet_parameters["element-path"]) else: - trans_xsl = os.path.join(self.resource_dir, "config_output.xsl") - template_xml = os.path.join(self.resource_dir, "config_template.xhtml") - XSLForms.Prepare.ensure_stylesheet(template_xml, trans_xsl) + trans_xsl = self.prepare_output("configuration") + + # Add information essential for in-page requests. stylesheet_parameters["application-url"] = \ "http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query()) # Complete the response. - proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters) - proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(), - configuration) + self.send_output(trans, [trans_xsl], stylesheet_parameters, configuration) #import sys #proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters)