1.1 --- a/examples/Common/Configurator/__init__.py Fri May 06 19:10:57 2005 +0000
1.2 +++ b/examples/Common/Configurator/__init__.py Fri May 06 19:12:27 2005 +0000
1.3 @@ -5,6 +5,7 @@
1.4 import WebStack.Generic
1.5 import XSLForms.Fields
1.6 import XSLForms.Output
1.7 +import XSLForms.Prepare
1.8 import XSLOutput
1.9 import libxml2dom
1.10 import os
1.11 @@ -56,9 +57,11 @@
1.12 fields = XSLForms.Fields.Fields(encoding=self.encoding, values_are_lists=1)
1.13 if path_info == "/cpu":
1.14 text = trans.get_request_stream().read()
1.15 - text_parts = text.split("=")
1.16 - text_name, text_values = text_parts[0], ["=".join(text_parts[1:])]
1.17 - parameters = {text_name : text_values}
1.18 + parameters = {}
1.19 + for text_line in text.split("\r\n"):
1.20 + text_parts = text_line.split("=")
1.21 + text_name, text_values = text_parts[0], ["=".join(text_parts[1:])]
1.22 + parameters[text_name] = text_values
1.23 else:
1.24 parameters = trans.get_fields_from_body(self.encoding)
1.25 documents = fields.make_documents(parameters.items())
1.26 @@ -107,28 +110,36 @@
1.27
1.28 trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding))
1.29
1.30 + # Define the stylesheet parameters.
1.31 +
1.32 + stylesheet_parameters = {}
1.33 +
1.34 # Ensure that an output stylesheet exists.
1.35
1.36 trans_xsl = os.path.join(self.resource_dir, "config_output.xsl")
1.37 template_xml = os.path.join(self.resource_dir, "config_template.xhtml")
1.38 -
1.39 - if not os.path.exists(trans_xsl) or \
1.40 - os.path.getmtime(trans_xsl) < os.path.getmtime(template_xml):
1.41 + XSLForms.Prepare.ensure_stylesheet(template_xml, trans_xsl)
1.42
1.43 - import XSLForms.Prepare
1.44 - template_xml = os.path.join(self.resource_dir, "config_template.xhtml")
1.45 - XSLForms.Prepare.make_stylesheet(template_xml, trans_xsl)
1.46 + if path_info == "/cpu":
1.47 + trans_xsl = os.path.join(self.resource_dir, "config_output_cpu.xsl")
1.48 + template_xml = os.path.join(self.resource_dir, "config_output.xsl")
1.49 + XSLForms.Prepare.ensure_stylesheet_fragment(template_xml, trans_xsl, "cpu-node")
1.50 + target_field_name = parameters.get("target-field-name", [""])[0]
1.51 + print "*", target_field_name
1.52 + stylesheet_parameters["element-path"] = XSLForms.Output.get_element_path(target_field_name)
1.53 + print "*", stylesheet_parameters["element-path"]
1.54
1.55 - # Define the parameters.
1.56 -
1.57 - parameters = {
1.58 - "application-url" : "http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query())
1.59 - }
1.60 + stylesheet_parameters["application-url"] = \
1.61 + "http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query())
1.62
1.63 # Complete the response.
1.64
1.65 - proc = XSLOutput.Processor([trans_xsl], parameters=parameters)
1.66 + proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters)
1.67 proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(),
1.68 configuration)
1.69
1.70 + import sys
1.71 + proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters)
1.72 + proc.send_output(sys.stderr, "iso-8859-1", configuration)
1.73 +
1.74 # vim: tabstop=4 expandtab shiftwidth=4