# HG changeset patch # User paulb # Date 1115406747 0 # Node ID 27b94701b0277fbff941edbb3714600fc20e1c34 # Parent c362c7c95959283c22bc651259e7e693109d30a7 [project @ 2005-05-06 19:12:27 by paulb] Introduced code to handle partial document updates using additional request parameters and information for the part of the document to be updated. diff -r c362c7c95959 -r 27b94701b027 examples/Common/Configurator/__init__.py --- a/examples/Common/Configurator/__init__.py Fri May 06 19:10:57 2005 +0000 +++ b/examples/Common/Configurator/__init__.py Fri May 06 19:12:27 2005 +0000 @@ -5,6 +5,7 @@ import WebStack.Generic import XSLForms.Fields import XSLForms.Output +import XSLForms.Prepare import XSLOutput import libxml2dom import os @@ -56,9 +57,11 @@ fields = XSLForms.Fields.Fields(encoding=self.encoding, values_are_lists=1) if path_info == "/cpu": text = trans.get_request_stream().read() - text_parts = text.split("=") - text_name, text_values = text_parts[0], ["=".join(text_parts[1:])] - parameters = {text_name : text_values} + parameters = {} + for text_line in text.split("\r\n"): + text_parts = text_line.split("=") + text_name, text_values = text_parts[0], ["=".join(text_parts[1:])] + parameters[text_name] = text_values else: parameters = trans.get_fields_from_body(self.encoding) documents = fields.make_documents(parameters.items()) @@ -107,28 +110,36 @@ trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding)) + # Define the stylesheet parameters. + + stylesheet_parameters = {} + # Ensure that an output stylesheet exists. trans_xsl = os.path.join(self.resource_dir, "config_output.xsl") template_xml = os.path.join(self.resource_dir, "config_template.xhtml") - - if not os.path.exists(trans_xsl) or \ - os.path.getmtime(trans_xsl) < os.path.getmtime(template_xml): + XSLForms.Prepare.ensure_stylesheet(template_xml, trans_xsl) - import XSLForms.Prepare - template_xml = os.path.join(self.resource_dir, "config_template.xhtml") - XSLForms.Prepare.make_stylesheet(template_xml, trans_xsl) + if path_info == "/cpu": + trans_xsl = os.path.join(self.resource_dir, "config_output_cpu.xsl") + template_xml = os.path.join(self.resource_dir, "config_output.xsl") + XSLForms.Prepare.ensure_stylesheet_fragment(template_xml, trans_xsl, "cpu-node") + target_field_name = parameters.get("target-field-name", [""])[0] + print "*", target_field_name + stylesheet_parameters["element-path"] = XSLForms.Output.get_element_path(target_field_name) + print "*", stylesheet_parameters["element-path"] - # Define the parameters. - - parameters = { - "application-url" : "http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query()) - } + 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=parameters) + proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters) proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(), configuration) + import sys + proc = XSLOutput.Processor([trans_xsl], parameters=stylesheet_parameters) + proc.send_output(sys.stderr, "iso-8859-1", configuration) + # vim: tabstop=4 expandtab shiftwidth=4