1.1 --- a/README.txt Wed Aug 24 16:07:04 2005 +0000
1.2 +++ b/README.txt Wed Aug 24 18:50:10 2005 +0000
1.3 @@ -55,8 +55,12 @@
1.4 New in WebStack 1.0 (Changes since WebStack 0.10)
1.5 -------------------------------------------------
1.6
1.7 -Changed the behaviour of get_fields_from_path to return Unicode data decoded
1.8 -using the optional encoding parameter or a common default encoding.
1.9 +Changed the behaviour of get_path, get_path_without_query, get_path_info and
1.10 +get_fields_from_path to return Unicode data decoded using the optional
1.11 +encoding parameter or a common default encoding.
1.12 +Added convenience methods to Transaction for the decoding and encoding of path
1.13 +values (to and from Unicode objects) - see the decode_path and encode_path
1.14 +methods.
1.15 Added Debian package support.
1.16 Added automatic session directory creation for the WebStack sessions
1.17 implementation.
1.18 @@ -69,9 +73,6 @@
1.19 from Scott Robinson).
1.20 Fixed ResourceMap.MapResource to handle non-existent resources properly (where
1.21 the virtual path info is only one component in length).
1.22 -Added convenience methods to Transaction for the decoding and encoding of path
1.23 -values (to and from Unicode objects) - see the decode_path and encode_path
1.24 -methods.
1.25
1.26 New in WebStack 0.10 (Changes since WebStack 0.9)
1.27 -------------------------------------------------
2.1 --- a/WebStack/BaseHTTPRequestHandler.py Wed Aug 24 16:07:04 2005 +0000
2.2 +++ b/WebStack/BaseHTTPRequestHandler.py Wed Aug 24 18:50:10 2005 +0000
2.3 @@ -189,32 +189,56 @@
2.4
2.5 return self.parse_content_preferences(self.trans.headers.get("accept-language"))
2.6
2.7 - def get_path(self):
2.8 + def get_path(self, encoding=None):
2.9
2.10 """
2.11 - Returns the entire path from the request.
2.12 + Returns the entire path from the request as a Unicode object. Any "URL
2.13 + encoded" character values in the part of the path before the query
2.14 + string will be decoded and presented as genuine characters; the query
2.15 + string will remain "URL encoded", however.
2.16 +
2.17 + If the optional 'encoding' is set, use that in preference to the default
2.18 + encoding to convert the path into a form not containing "URL encoded"
2.19 + character values.
2.20 """
2.21
2.22 - return self.trans.path
2.23 + path = self.get_path_without_query(encoding)
2.24 + qs = self.get_query_string()
2.25 + if qs:
2.26 + return path + "?" + qs
2.27 + else:
2.28 + return path
2.29
2.30 - def get_path_without_query(self):
2.31 + def get_path_without_query(self, encoding=None):
2.32
2.33 """
2.34 - Returns the entire path from the request minus the query string.
2.35 + Returns the entire path from the request minus the query string as a
2.36 + Unicode object containing genuine characters (as opposed to "URL
2.37 + encoded" character values).
2.38 +
2.39 + If the optional 'encoding' is set, use that in preference to the default
2.40 + encoding to convert the path into a form not containing "URL encoded"
2.41 + character values.
2.42 """
2.43
2.44 # Remove the query string from the end of the path.
2.45
2.46 - return self.trans.path.split("?")[0]
2.47 + return self.decode_path(self.trans.path.split("?")[0], encoding)
2.48
2.49 - def get_path_info(self):
2.50 + def get_path_info(self, encoding=None):
2.51
2.52 """
2.53 Returns the "path info" (the part of the URL after the resource name
2.54 - handling the current request) from the request.
2.55 + handling the current request) from the request as a Unicode object
2.56 + containing genuine characters (as opposed to "URL encoded" character
2.57 + values).
2.58 +
2.59 + If the optional 'encoding' is set, use that in preference to the default
2.60 + encoding to convert the path into a form not containing "URL encoded"
2.61 + character values.
2.62 """
2.63
2.64 - return self.get_path_without_query()
2.65 + return self.get_path_without_query(encoding)
2.66
2.67 def get_query_string(self):
2.68
3.1 --- a/WebStack/CGI.py Wed Aug 24 16:07:04 2005 +0000
3.2 +++ b/WebStack/CGI.py Wed Aug 24 18:50:10 2005 +0000
3.3 @@ -176,38 +176,56 @@
3.4
3.5 return self.parse_content_preferences(None)
3.6
3.7 - def get_path(self):
3.8 + def get_path(self, encoding=None):
3.9
3.10 """
3.11 - Returns the entire path from the request.
3.12 + Returns the entire path from the request as a Unicode object. Any "URL
3.13 + encoded" character values in the part of the path before the query
3.14 + string will be decoded and presented as genuine characters; the query
3.15 + string will remain "URL encoded", however.
3.16 +
3.17 + If the optional 'encoding' is set, use that in preference to the default
3.18 + encoding to convert the path into a form not containing "URL encoded"
3.19 + character values.
3.20 """
3.21
3.22 - path = self.get_path_without_query()
3.23 + path = self.get_path_without_query(encoding)
3.24 qs = self.get_query_string()
3.25 if qs:
3.26 - path += "?"
3.27 - path += qs
3.28 + return path + "?" + qs
3.29 + else:
3.30 + return path
3.31 +
3.32 + def get_path_without_query(self, encoding=None):
3.33 +
3.34 + """
3.35 + Returns the entire path from the request minus the query string as a
3.36 + Unicode object containing genuine characters (as opposed to "URL
3.37 + encoded" character values).
3.38 +
3.39 + If the optional 'encoding' is set, use that in preference to the default
3.40 + encoding to convert the path into a form not containing "URL encoded"
3.41 + character values.
3.42 + """
3.43 +
3.44 + path = self.decode_path(self.env.get("SCRIPT_NAME") or "", encoding)
3.45 + path += self.get_path_info(encoding)
3.46 return path
3.47
3.48 - def get_path_without_query(self):
3.49 -
3.50 - """
3.51 - Returns the entire path from the request minus the query string.
3.52 - """
3.53 -
3.54 - path = self.env.get("SCRIPT_NAME") or ""
3.55 - if self.env.has_key("PATH_INFO"):
3.56 - path += self.env["PATH_INFO"]
3.57 - return path
3.58 -
3.59 - def get_path_info(self):
3.60 + def get_path_info(self, encoding=None):
3.61
3.62 """
3.63 Returns the "path info" (the part of the URL after the resource name
3.64 - handling the current request) from the request.
3.65 + handling the current request) from the request as a Unicode object
3.66 + containing genuine characters (as opposed to "URL encoded" character
3.67 + values).
3.68 +
3.69 + If the optional 'encoding' is set, use that in preference to the default
3.70 + encoding to convert the path into a form not containing "URL encoded"
3.71 + character values.
3.72 """
3.73
3.74 - return self.env.get("PATH_INFO") or ""
3.75 + return self.decode_path(self.env.get("PATH_INFO") or "", encoding)
3.76
3.77 def get_query_string(self):
3.78
4.1 --- a/WebStack/Generic.py Wed Aug 24 16:07:04 2005 +0000
4.2 +++ b/WebStack/Generic.py Wed Aug 24 18:50:10 2005 +0000
4.3 @@ -365,27 +365,46 @@
4.4
4.5 raise NotImplementedError, "get_content_languages"
4.6
4.7 - def get_path(self):
4.8 + def get_path(self, encoding=None):
4.9
4.10 """
4.11 - Returns the entire path from the request.
4.12 + Returns the entire path from the request as a Unicode object. Any "URL
4.13 + encoded" character values in the part of the path before the query
4.14 + string will be decoded and presented as genuine characters; the query
4.15 + string will remain "URL encoded", however.
4.16 +
4.17 + If the optional 'encoding' is set, use that in preference to the default
4.18 + encoding to convert the path into a form not containing "URL encoded"
4.19 + character values.
4.20 """
4.21
4.22 raise NotImplementedError, "get_path"
4.23
4.24 - def get_path_without_query(self):
4.25 + def get_path_without_query(self, encoding=None):
4.26
4.27 """
4.28 - Returns the entire path from the request minus the query string.
4.29 + Returns the entire path from the request minus the query string as a
4.30 + Unicode object containing genuine characters (as opposed to "URL
4.31 + encoded" character values).
4.32 +
4.33 + If the optional 'encoding' is set, use that in preference to the default
4.34 + encoding to convert the path into a form not containing "URL encoded"
4.35 + character values.
4.36 """
4.37
4.38 raise NotImplementedError, "get_path_without_query"
4.39
4.40 - def get_path_info(self):
4.41 + def get_path_info(self, encoding=None):
4.42
4.43 """
4.44 Returns the "path info" (the part of the URL after the resource name
4.45 - handling the current request) from the request.
4.46 + handling the current request) from the request as a Unicode object
4.47 + containing genuine characters (as opposed to "URL encoded" character
4.48 + values).
4.49 +
4.50 + If the optional 'encoding' is set, use that in preference to the default
4.51 + encoding to convert the path into a form not containing "URL encoded"
4.52 + character values.
4.53 """
4.54
4.55 raise NotImplementedError, "get_path_info"
5.1 --- a/WebStack/JavaServlet.py Wed Aug 24 16:07:04 2005 +0000
5.2 +++ b/WebStack/JavaServlet.py Wed Aug 24 18:50:10 2005 +0000
5.3 @@ -211,34 +211,53 @@
5.4 else:
5.5 return None
5.6
5.7 - def get_path(self):
5.8 + def get_path(self, encoding=None):
5.9
5.10 """
5.11 - Returns the entire path from the request.
5.12 + Returns the entire path from the request as a Unicode object. Any "URL
5.13 + encoded" character values in the part of the path before the query
5.14 + string will be decoded and presented as genuine characters; the query
5.15 + string will remain "URL encoded", however.
5.16 +
5.17 + If the optional 'encoding' is set, use that in preference to the default
5.18 + encoding to convert the path into a form not containing "URL encoded"
5.19 + character values.
5.20 """
5.21
5.22 # NOTE: To be verified.
5.23
5.24 - path = self.get_path_without_query()
5.25 + path = self.get_path_without_query(encoding)
5.26 qs = self.get_query_string()
5.27 if qs:
5.28 - path += "?"
5.29 - path += qs
5.30 - return path
5.31 + return path = "?" + qs
5.32 + else:
5.33 + return path
5.34
5.35 - def get_path_without_query(self):
5.36 + def get_path_without_query(self, encoding=None):
5.37
5.38 """
5.39 - Returns the entire path from the request minus the query string.
5.40 + Returns the entire path from the request minus the query string as a
5.41 + Unicode object containing genuine characters (as opposed to "URL
5.42 + encoded" character values).
5.43 +
5.44 + If the optional 'encoding' is set, use that in preference to the default
5.45 + encoding to convert the path into a form not containing "URL encoded"
5.46 + character values.
5.47 """
5.48
5.49 - return self.request.getContextPath() + self.request.getServletPath() + self.get_path_info()
5.50 + return self.request.getContextPath() + self.request.getServletPath() + self.get_path_info(encoding)
5.51
5.52 - def get_path_info(self):
5.53 + def get_path_info(self, encoding=None):
5.54
5.55 """
5.56 Returns the "path info" (the part of the URL after the resource name
5.57 - handling the current request) from the request.
5.58 + handling the current request) from the request as a Unicode object
5.59 + containing genuine characters (as opposed to "URL encoded" character
5.60 + values).
5.61 +
5.62 + If the optional 'encoding' is set, use that in preference to the default
5.63 + encoding to convert the path into a form not containing "URL encoded"
5.64 + character values.
5.65 """
5.66
5.67 return self.request.getPathInfo() or ""
6.1 --- a/WebStack/ModPython.py Wed Aug 24 16:07:04 2005 +0000
6.2 +++ b/WebStack/ModPython.py Wed Aug 24 18:50:10 2005 +0000
6.3 @@ -171,34 +171,53 @@
6.4
6.5 return self.parse_content_preferences(self.trans.headers_in.get("Accept-Language"))
6.6
6.7 - def get_path(self):
6.8 + def get_path(self, encoding=None):
6.9
6.10 """
6.11 - Returns the entire path from the request.
6.12 + Returns the entire path from the request as a Unicode object. Any "URL
6.13 + encoded" character values in the part of the path before the query
6.14 + string will be decoded and presented as genuine characters; the query
6.15 + string will remain "URL encoded", however.
6.16 +
6.17 + If the optional 'encoding' is set, use that in preference to the default
6.18 + encoding to convert the path into a form not containing "URL encoded"
6.19 + character values.
6.20 """
6.21
6.22 query_string = self.get_query_string()
6.23 if query_string:
6.24 - return self.trans.uri + "?" + query_string
6.25 + return self.decode_path(self.trans.uri, encoding) + "?" + query_string
6.26 else:
6.27 - return self.trans.uri
6.28 + return self.decode_path(self.trans.uri, encoding)
6.29
6.30 - def get_path_without_query(self):
6.31 + def get_path_without_query(self, encoding=None):
6.32
6.33 """
6.34 - Returns the entire path from the request minus the query string.
6.35 + Returns the entire path from the request minus the query string as a
6.36 + Unicode object containing genuine characters (as opposed to "URL
6.37 + encoded" character values).
6.38 +
6.39 + If the optional 'encoding' is set, use that in preference to the default
6.40 + encoding to convert the path into a form not containing "URL encoded"
6.41 + character values.
6.42 """
6.43
6.44 - return self.trans.uri
6.45 + return self.decode_path(self.trans.uri, encoding)
6.46
6.47 - def get_path_info(self):
6.48 + def get_path_info(self, encoding=None):
6.49
6.50 """
6.51 Returns the "path info" (the part of the URL after the resource name
6.52 - handling the current request) from the request.
6.53 + handling the current request) from the request as a Unicode object
6.54 + containing genuine characters (as opposed to "URL encoded" character
6.55 + values).
6.56 +
6.57 + If the optional 'encoding' is set, use that in preference to the default
6.58 + encoding to convert the path into a form not containing "URL encoded"
6.59 + character values.
6.60 """
6.61
6.62 - return self.trans.path_info
6.63 + return self.decode_path(self.trans.path_info, encoding)
6.64
6.65 def get_query_string(self):
6.66
6.67 @@ -263,9 +282,10 @@
6.68
6.69 fields = {}
6.70 for field in self.storage_body.list:
6.71 - if not fields.has_key(field.name):
6.72 - fields[field.name] = []
6.73 - fields[field.name].append(get_body_field(field.value, encoding))
6.74 + field_name = self.decode_path(field.name, encoding)
6.75 + if not fields.has_key(field_name):
6.76 + fields[field_name] = []
6.77 + fields[field_name].append(get_body_field(field.value, encoding))
6.78 return fields
6.79
6.80 def get_fields(self, encoding=None):
7.1 --- a/WebStack/Twisted.py Wed Aug 24 16:07:04 2005 +0000
7.2 +++ b/WebStack/Twisted.py Wed Aug 24 18:50:10 2005 +0000
7.3 @@ -140,30 +140,54 @@
7.4
7.5 return self.parse_content_preferences(self.trans.getHeader("Accept-Charset"))
7.6
7.7 - def get_path(self):
7.8 + def get_path(self, encoding=None):
7.9
7.10 """
7.11 - Returns the entire path from the request.
7.12 + Returns the entire path from the request as a Unicode object. Any "URL
7.13 + encoded" character values in the part of the path before the query
7.14 + string will be decoded and presented as genuine characters; the query
7.15 + string will remain "URL encoded", however.
7.16 +
7.17 + If the optional 'encoding' is set, use that in preference to the default
7.18 + encoding to convert the path into a form not containing "URL encoded"
7.19 + character values.
7.20 """
7.21
7.22 - return self.trans.uri
7.23 + path = self.get_path_without_query(encoding)
7.24 + qs = self.get_query_string()
7.25 + if qs:
7.26 + return path + "?" + qs
7.27 + else:
7.28 + return path
7.29
7.30 - def get_path_without_query(self):
7.31 + def get_path_without_query(self, encoding=None):
7.32
7.33 """
7.34 - Returns the entire path from the request minus the query string.
7.35 + Returns the entire path from the request minus the query string as a
7.36 + Unicode object containing genuine characters (as opposed to "URL
7.37 + encoded" character values).
7.38 +
7.39 + If the optional 'encoding' is set, use that in preference to the default
7.40 + encoding to convert the path into a form not containing "URL encoded"
7.41 + character values.
7.42 """
7.43
7.44 - return self.get_path().split("?")[0]
7.45 + return self.decode_path(self.trans.uri.split("?")[0], encoding)
7.46
7.47 - def get_path_info(self):
7.48 + def get_path_info(self, encoding=None):
7.49
7.50 """
7.51 Returns the "path info" (the part of the URL after the resource name
7.52 - handling the current request) from the request.
7.53 + handling the current request) from the request as a Unicode object
7.54 + containing genuine characters (as opposed to "URL encoded" character
7.55 + values).
7.56 +
7.57 + If the optional 'encoding' is set, use that in preference to the default
7.58 + encoding to convert the path into a form not containing "URL encoded"
7.59 + character values.
7.60 """
7.61
7.62 - return "/%s" % "/".join(self.trans.postpath)
7.63 + return self.decode_path("/%s" % "/".join(self.trans.postpath), encoding)
7.64
7.65 def get_query_string(self):
7.66
7.67 @@ -171,7 +195,7 @@
7.68 Returns the query string from the path in the request.
7.69 """
7.70
7.71 - t = self.get_path().split("?")
7.72 + t = self.trans.uri.split("?")
7.73 if len(t) == 1:
7.74 return ""
7.75 else:
7.76 @@ -231,6 +255,11 @@
7.77 fields = {}
7.78 for field_name, field_values in self.trans.args.items():
7.79
7.80 + # NOTE: Need to use the special path decoding method due to the
7.81 + # NOTE: mixing of path and body fields within Twisted.
7.82 +
7.83 + field_name = self.decode_path(field_name, encoding)
7.84 +
7.85 # Find the body values.
7.86
7.87 if type(field_values) == type([]):
8.1 --- a/WebStack/WSGI.py Wed Aug 24 16:07:04 2005 +0000
8.2 +++ b/WebStack/WSGI.py Wed Aug 24 18:50:10 2005 +0000
8.3 @@ -180,38 +180,56 @@
8.4
8.5 return self.parse_content_preferences(None)
8.6
8.7 - def get_path(self):
8.8 + def get_path(self, encoding=None):
8.9
8.10 """
8.11 - Returns the entire path from the request.
8.12 + Returns the entire path from the request as a Unicode object. Any "URL
8.13 + encoded" character values in the part of the path before the query
8.14 + string will be decoded and presented as genuine characters; the query
8.15 + string will remain "URL encoded", however.
8.16 +
8.17 + If the optional 'encoding' is set, use that in preference to the default
8.18 + encoding to convert the path into a form not containing "URL encoded"
8.19 + character values.
8.20 """
8.21
8.22 - path = self.get_path_without_query()
8.23 + path = self.get_path_without_query(encoding)
8.24 qs = self.get_query_string()
8.25 if qs:
8.26 - path += "?"
8.27 - path += qs
8.28 + return path + "?" + qs
8.29 + else:
8.30 + return path
8.31 +
8.32 + def get_path_without_query(self, encoding=None):
8.33 +
8.34 + """
8.35 + Returns the entire path from the request minus the query string as a
8.36 + Unicode object containing genuine characters (as opposed to "URL
8.37 + encoded" character values).
8.38 +
8.39 + If the optional 'encoding' is set, use that in preference to the default
8.40 + encoding to convert the path into a form not containing "URL encoded"
8.41 + character values.
8.42 + """
8.43 +
8.44 + path = self.decode_path(self.env.get("SCRIPT_NAME") or "", encoding)
8.45 + path += self.get_path_info(encoding)
8.46 return path
8.47
8.48 - def get_path_without_query(self):
8.49 -
8.50 - """
8.51 - Returns the entire path from the request minus the query string.
8.52 - """
8.53 -
8.54 - path = self.env.get("SCRIPT_NAME") or ""
8.55 - if self.env.has_key("PATH_INFO"):
8.56 - path += self.env["PATH_INFO"]
8.57 - return path
8.58 -
8.59 - def get_path_info(self):
8.60 + def get_path_info(self, encoding=None):
8.61
8.62 """
8.63 Returns the "path info" (the part of the URL after the resource name
8.64 - handling the current request) from the request.
8.65 + handling the current request) from the request as a Unicode object
8.66 + containing genuine characters (as opposed to "URL encoded" character
8.67 + values).
8.68 +
8.69 + If the optional 'encoding' is set, use that in preference to the default
8.70 + encoding to convert the path into a form not containing "URL encoded"
8.71 + character values.
8.72 """
8.73
8.74 - return self.env.get("PATH_INFO") or ""
8.75 + return self.decode_path(self.env.get("PATH_INFO") or "", encoding)
8.76
8.77 def get_query_string(self):
8.78
9.1 --- a/WebStack/Webware.py Wed Aug 24 16:07:04 2005 +0000
9.2 +++ b/WebStack/Webware.py Wed Aug 24 18:50:10 2005 +0000
9.3 @@ -150,35 +150,60 @@
9.4
9.5 return self.trans.request().contentLanguages()
9.6
9.7 - def get_path(self):
9.8 + def get_path(self, encoding=None):
9.9
9.10 """
9.11 - Returns the entire path from the request.
9.12 + Returns the entire path from the request as a Unicode object. Any "URL
9.13 + encoded" character values in the part of the path before the query
9.14 + string will be decoded and presented as genuine characters; the query
9.15 + string will remain "URL encoded", however.
9.16 +
9.17 + If the optional 'encoding' is set, use that in preference to the default
9.18 + encoding to convert the path into a form not containing "URL encoded"
9.19 + character values.
9.20 """
9.21
9.22 - return self.trans.request().uri()
9.23 + path = self.get_path_without_query(encoding)
9.24 + qs = self.get_query_string()
9.25 + if qs:
9.26 + return path + "?" + qs
9.27 + else:
9.28 + return path
9.29
9.30 - def get_path_without_query(self):
9.31 + def get_path_without_query(self, encoding=None):
9.32
9.33 """
9.34 - Returns the entire path from the request minus the query string.
9.35 + Returns the entire path from the request minus the query string as a
9.36 + Unicode object containing genuine characters (as opposed to "URL
9.37 + encoded" character values).
9.38 +
9.39 + If the optional 'encoding' is set, use that in preference to the default
9.40 + encoding to convert the path into a form not containing "URL encoded"
9.41 + character values.
9.42 """
9.43
9.44 - return self.get_path().split("?")[0]
9.45 + return self.decode_path(self.trans.request().uri().split("?")[0], encoding)
9.46
9.47 - def get_path_info(self):
9.48 + def get_path_info(self, encoding=None):
9.49
9.50 """
9.51 Returns the "path info" (the part of the URL after the resource name
9.52 - handling the current request) from the request.
9.53 + handling the current request) from the request as a Unicode object
9.54 + containing genuine characters (as opposed to "URL encoded" character
9.55 + values).
9.56 +
9.57 + If the optional 'encoding' is set, use that in preference to the default
9.58 + encoding to convert the path into a form not containing "URL encoded"
9.59 + character values.
9.60 """
9.61
9.62 path_info = self.trans.request().pathInfo()
9.63 context_name = self.trans.request().contextName()
9.64 if path_info.startswith(context_name):
9.65 - return path_info[len(context_name):]
9.66 + real_path_info = path_info[len(context_name):]
9.67 else:
9.68 - return path_info
9.69 + real_path_info = path_info
9.70 + return self.decode_path(real_path_info, encoding)
9.71
9.72 def get_query_string(self):
9.73
10.1 --- a/WebStack/Zope.py Wed Aug 24 16:07:04 2005 +0000
10.2 +++ b/WebStack/Zope.py Wed Aug 24 18:50:10 2005 +0000
10.3 @@ -146,44 +146,63 @@
10.4
10.5 return self.parse_content_preferences(None)
10.6
10.7 - def get_path(self):
10.8 + def get_path(self, encoding=None):
10.9
10.10 """
10.11 - Returns the entire path from the request.
10.12 + Returns the entire path from the request as a Unicode object. Any "URL
10.13 + encoded" character values in the part of the path before the query
10.14 + string will be decoded and presented as genuine characters; the query
10.15 + string will remain "URL encoded", however.
10.16 +
10.17 + If the optional 'encoding' is set, use that in preference to the default
10.18 + encoding to convert the path into a form not containing "URL encoded"
10.19 + character values.
10.20 """
10.21
10.22 # NOTE: Based on WebStack.CGI.get_path.
10.23
10.24 - path = self.get_path_without_query()
10.25 + path = self.get_path_without_query(encoding)
10.26 qs = self.get_query_string()
10.27 if qs:
10.28 - path += "?"
10.29 - path += qs
10.30 - return path
10.31 + return path + "?" + qs
10.32 + else:
10.33 + return path
10.34
10.35 - def get_path_without_query(self):
10.36 + def get_path_without_query(self, encoding=None):
10.37
10.38 """
10.39 - Returns the entire path from the request minus the query string.
10.40 + Returns the entire path from the request minus the query string as a
10.41 + Unicode object containing genuine characters (as opposed to "URL
10.42 + encoded" character values).
10.43 +
10.44 + If the optional 'encoding' is set, use that in preference to the default
10.45 + encoding to convert the path into a form not containing "URL encoded"
10.46 + character values.
10.47 """
10.48
10.49 # NOTE: Based on WebStack.CGI.get_path.
10.50
10.51 - path = self.request.environ.get("SCRIPT_NAME") or ""
10.52 - if self.request.environ.has_key("PATH_INFO"):
10.53 - path += self.request.environ["PATH_INFO"]
10.54 + path = self.decode_path(self.request.environ.get("SCRIPT_NAME") or "", encoding)
10.55 + path += self.get_path_info(encoding)
10.56 return path
10.57
10.58 - def get_path_info(self):
10.59 + def get_path_info(self, encoding=None):
10.60
10.61 """
10.62 Returns the "path info" (the part of the URL after the resource name
10.63 - handling the current request) from the request.
10.64 + handling the current request) from the request as a Unicode object
10.65 + containing genuine characters (as opposed to "URL encoded" character
10.66 + values).
10.67 +
10.68 + If the optional 'encoding' is set, use that in preference to the default
10.69 + encoding to convert the path into a form not containing "URL encoded"
10.70 + character values.
10.71 """
10.72
10.73 product_path = "/".join(self.adapter.getPhysicalPath())
10.74 path_info = self.request.environ.get("PATH_INFO") or ""
10.75 - return path_info[len(product_path):]
10.76 + real_path_info = path_info[len(product_path):]
10.77 + return self.decode_path(real_path_info, encoding)
10.78
10.79 def get_query_string(self):
10.80