1.1 --- a/examples/Common/Candidate/__init__.py Sun Jan 21 00:22:40 2007 +0000
1.2 +++ b/examples/Common/Candidate/__init__.py Sun Jan 21 00:23:27 2007 +0000
1.3 @@ -12,8 +12,13 @@
1.4 # Site map imports.
1.5
1.6 from WebStack.Resources.ResourceMap import MapResource
1.7 +from WebStack.Resources.Selectors import EncodingSelector
1.8 from WebStack.Resources.Static import DirectoryResource
1.9
1.10 +# Configuration setting.
1.11 +
1.12 +encoding = "utf-8"
1.13 +
1.14 # Resource classes.
1.15
1.16 class AdminResource(XSLForms.Resources.WebResources.XSLFormsResource):
1.17 @@ -21,7 +26,6 @@
1.18 "A resource providing administration facilities for job candidate profiles."
1.19
1.20 resource_dir = os.path.join(os.path.split(__file__)[0], "Resources")
1.21 - encoding = "utf-8"
1.22 template_resources = {
1.23 "admin" : ("admin_template.xhtml", "admin_output.xsl")
1.24 }
1.25 @@ -45,9 +49,9 @@
1.26 # Get the "show" and "edit" resource paths.
1.27 # NOTE: These should be obtained from the site map.
1.28
1.29 - vpath = trans.get_processed_virtual_path_info(self.path_encoding)
1.30 - show_path = trans.get_path_without_info(self.path_encoding) + trans.update_path(vpath, "show")
1.31 - edit_path = trans.get_path_without_info(self.path_encoding) + trans.update_path(vpath, "edit")
1.32 + vpath = trans.get_processed_virtual_path_info()
1.33 + show_path = trans.get_path_without_info() + trans.update_path(vpath, "show")
1.34 + edit_path = trans.get_path_without_info() + trans.update_path(vpath, "edit")
1.35
1.36 # Ensure the presence of a document.
1.37
1.38 @@ -63,12 +67,12 @@
1.39 selectors = form.get_selectors()
1.40 if selectors.has_key("show"):
1.41 name = selectors["show"][0].getAttribute("name")
1.42 - trans.redirect(trans.encode_path(show_path, self.path_encoding) +
1.43 - "?name=%s" % trans.encode_path(name, self.path_encoding))
1.44 + trans.redirect(trans.encode_path(show_path) +
1.45 + "?name=%s" % trans.encode_path(name))
1.46 elif selectors.has_key("edit"):
1.47 name = selectors["edit"][0].getAttribute("name")
1.48 - trans.redirect(trans.encode_path(edit_path, self.path_encoding) +
1.49 - "?name=%s" % trans.encode_path(name, self.path_encoding))
1.50 + trans.redirect(trans.encode_path(edit_path) +
1.51 + "?name=%s" % trans.encode_path(name))
1.52
1.53 # Add and remove elements according to the selectors found.
1.54
1.55 @@ -97,7 +101,7 @@
1.56
1.57 # Start the response.
1.58
1.59 - trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", self.encoding))
1.60 + trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", encoding))
1.61
1.62 # Ensure that an output stylesheet exists.
1.63
1.64 @@ -113,7 +117,6 @@
1.65 "A resource providing editing facilities for a job candidate profile."
1.66
1.67 resource_dir = os.path.join(os.path.split(__file__)[0], "Resources")
1.68 - encoding = "utf-8"
1.69 template_resources = {
1.70 "candidate_display" : ("candidate_display_template.xhtml", "candidate_display_output.xsl")
1.71 }
1.72 @@ -136,7 +139,7 @@
1.73
1.74 parameters = form.get_parameters()
1.75 documents = form.get_documents()
1.76 - fields = trans.get_fields_from_path(self.path_encoding)
1.77 + fields = trans.get_fields_from_path()
1.78 name = fields.get("name", [u"None"])[0]
1.79
1.80 # Ensure the presence of a document.
1.81 @@ -157,7 +160,7 @@
1.82
1.83 # Start the response.
1.84
1.85 - trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", self.encoding))
1.86 + trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", encoding))
1.87
1.88 # Ensure that an output stylesheet exists.
1.89 # Handle the "show" operation.
1.90 @@ -174,7 +177,6 @@
1.91 "A resource providing editing facilities for a job candidate profile."
1.92
1.93 resource_dir = os.path.join(os.path.split(__file__)[0], "Resources")
1.94 - encoding = "utf-8"
1.95 template_resources = {
1.96 "candidate" : ("candidate_template.xhtml", "candidate_output.xsl")
1.97 }
1.98 @@ -197,15 +199,15 @@
1.99
1.100 parameters = form.get_parameters()
1.101 documents = form.get_documents()
1.102 - fields = trans.get_fields_from_path(self.path_encoding)
1.103 + fields = trans.get_fields_from_path()
1.104 name = fields.get("name", [u"None"])[0]
1.105
1.106 # Get the "show" resource path.
1.107 # NOTE: This should be obtained from the site map.
1.108
1.109 - vpath = trans.get_processed_virtual_path_info(self.path_encoding)
1.110 - show_path = trans.get_path_without_info(self.path_encoding) + trans.update_path(vpath, "show")
1.111 - admin_path = trans.get_path_without_info(self.path_encoding) + trans.update_path(vpath, "")
1.112 + vpath = trans.get_processed_virtual_path_info()
1.113 + show_path = trans.get_path_without_info() + trans.update_path(vpath, "show")
1.114 + admin_path = trans.get_path_without_info() + trans.update_path(vpath, "")
1.115
1.116 # Ensure the presence of a document.
1.117
1.118 @@ -238,8 +240,8 @@
1.119 # Save the candidate information.
1.120
1.121 self.repository["candidate-%s" % name] = candidate.toString()
1.122 - trans.redirect(trans.encode_path(show_path, self.path_encoding) +
1.123 - "?name=%s" % trans.encode_path(name, self.path_encoding))
1.124 + trans.redirect(trans.encode_path(show_path) +
1.125 + "?name=%s" % trans.encode_path(name))
1.126
1.127 # Redirect if the administration interface is to be used.
1.128
1.129 @@ -248,11 +250,11 @@
1.130 # Save the candidate information.
1.131
1.132 self.repository["candidate-%s" % name] = candidate.toString()
1.133 - trans.redirect(trans.encode_path(admin_path, self.path_encoding))
1.134 + trans.redirect(trans.encode_path(admin_path))
1.135
1.136 # Start the response.
1.137
1.138 - trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", self.encoding))
1.139 + trans.set_content_type(WebStack.Generic.ContentType("application/xhtml+xml", encoding))
1.140
1.141 # Ensure that an output stylesheet exists.
1.142
1.143 @@ -289,7 +291,7 @@
1.144 "" : admin_resource
1.145 })
1.146
1.147 - return resource
1.148 + return EncodingSelector(resource, encoding)
1.149
1.150 # Resource preparation ahead of time - useful for making installations.
1.151