# HG changeset patch
# User paulb
# Date 1115590112 0
# Node ID c2d72da6df2d662c93e72bc626ea0d50bd828a00
# Parent 53eb9bde06fdcc5fd63c6a3739fae4d7890f4e76
[project @ 2005-05-08 22:08:14 by paulb]
Added the retrieval of document fragments for memory fields.
Added support for multiple field values.
diff -r 53eb9bde06fd -r c2d72da6df2d examples/Common/Configurator/Resources/config_template.xhtml
--- a/examples/Common/Configurator/Resources/config_template.xhtml Sun May 08 22:07:29 2005 +0000
+++ b/examples/Common/Configurator/Resources/config_template.xhtml Sun May 08 22:08:32 2005 +0000
@@ -20,7 +20,7 @@
Base System
Model
-
+
@@ -39,7 +39,7 @@
Memory
-
Memory unit
+
Memory unit
diff -r 53eb9bde06fd -r c2d72da6df2d examples/Common/Configurator/__init__.py
--- a/examples/Common/Configurator/__init__.py Sun May 08 22:07:29 2005 +0000
+++ b/examples/Common/Configurator/__init__.py Sun May 08 22:08:32 2005 +0000
@@ -55,15 +55,23 @@
documents = fields.make_documents(parameters.items())
elif method == "POST":
fields = XSLForms.Fields.Fields(encoding=self.encoding, values_are_lists=1)
- if path_info == "/cpu":
+
+ # Handle requests for fragments.
+
+ if path_info in ("/cpu", "/memory"):
text = trans.get_request_stream().read()
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
+ text_name, text_value = text_parts[0], "=".join(text_parts[1:])
+ if not parameters.has_key(text_name):
+ parameters[text_name] = []
+ parameters[text_name].append(text_value)
else:
parameters = trans.get_fields_from_body(self.encoding)
+
+ # Get the XML representation of the request.
+
documents = fields.make_documents(parameters.items())
print "*", libxml2dom.toString(documents["configuration"])
else:
@@ -129,6 +137,15 @@
stylesheet_parameters["element-path"] = XSLForms.Output.get_element_path(target_field_name)
print "*", stylesheet_parameters["element-path"]
+ elif path_info == "/memory":
+ trans_xsl = os.path.join(self.resource_dir, "config_output_memory.xsl")
+ template_xml = os.path.join(self.resource_dir, "config_output.xsl")
+ XSLForms.Prepare.ensure_stylesheet_fragment(template_xml, trans_xsl, "memory-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"]
+
stylesheet_parameters["application-url"] = \
"http://%s:%s%s" % (trans.get_server_name(), trans.get_server_port(), trans.get_path_without_query())