1.1 --- a/WebStack/WSGI.py Wed Aug 24 16:07:04 2005 +0000
1.2 +++ b/WebStack/WSGI.py Wed Aug 24 18:50:10 2005 +0000
1.3 @@ -180,38 +180,56 @@
1.4
1.5 return self.parse_content_preferences(None)
1.6
1.7 - def get_path(self):
1.8 + def get_path(self, encoding=None):
1.9
1.10 """
1.11 - Returns the entire path from the request.
1.12 + Returns the entire path from the request as a Unicode object. Any "URL
1.13 + encoded" character values in the part of the path before the query
1.14 + string will be decoded and presented as genuine characters; the query
1.15 + string will remain "URL encoded", however.
1.16 +
1.17 + If the optional 'encoding' is set, use that in preference to the default
1.18 + encoding to convert the path into a form not containing "URL encoded"
1.19 + character values.
1.20 """
1.21
1.22 - path = self.get_path_without_query()
1.23 + path = self.get_path_without_query(encoding)
1.24 qs = self.get_query_string()
1.25 if qs:
1.26 - path += "?"
1.27 - path += qs
1.28 + return path + "?" + qs
1.29 + else:
1.30 + return path
1.31 +
1.32 + def get_path_without_query(self, encoding=None):
1.33 +
1.34 + """
1.35 + Returns the entire path from the request minus the query string as a
1.36 + Unicode object containing genuine characters (as opposed to "URL
1.37 + encoded" character values).
1.38 +
1.39 + If the optional 'encoding' is set, use that in preference to the default
1.40 + encoding to convert the path into a form not containing "URL encoded"
1.41 + character values.
1.42 + """
1.43 +
1.44 + path = self.decode_path(self.env.get("SCRIPT_NAME") or "", encoding)
1.45 + path += self.get_path_info(encoding)
1.46 return path
1.47
1.48 - def get_path_without_query(self):
1.49 -
1.50 - """
1.51 - Returns the entire path from the request minus the query string.
1.52 - """
1.53 -
1.54 - path = self.env.get("SCRIPT_NAME") or ""
1.55 - if self.env.has_key("PATH_INFO"):
1.56 - path += self.env["PATH_INFO"]
1.57 - return path
1.58 -
1.59 - def get_path_info(self):
1.60 + def get_path_info(self, encoding=None):
1.61
1.62 """
1.63 Returns the "path info" (the part of the URL after the resource name
1.64 - handling the current request) from the request.
1.65 + handling the current request) from the request as a Unicode object
1.66 + containing genuine characters (as opposed to "URL encoded" character
1.67 + values).
1.68 +
1.69 + If the optional 'encoding' is set, use that in preference to the default
1.70 + encoding to convert the path into a form not containing "URL encoded"
1.71 + character values.
1.72 """
1.73
1.74 - return self.env.get("PATH_INFO") or ""
1.75 + return self.decode_path(self.env.get("PATH_INFO") or "", encoding)
1.76
1.77 def get_query_string(self):
1.78