# HG changeset patch # User paulb # Date 1124482858 0 # Node ID 160859a75f44c49a3bdff9966434c2a1fa0c873d # Parent 302cc102aaf65e0a2edc214d667fc8cb69501ef7 [project @ 2005-08-19 20:20:56 by paulb] Added convenience method. diff -r 302cc102aaf6 -r 160859a75f44 README.txt --- a/README.txt Fri Aug 19 13:27:38 2005 +0000 +++ b/README.txt Fri Aug 19 20:20:58 2005 +0000 @@ -66,6 +66,8 @@ different suggestion from Scott Robinson). Changed the ResourceMap.MapResource class to provide the empty string as the resource name where the virtual path info is only one component in length. +Added a convenience method to Transaction for the decoding of path values and +the production of Unicode objects - see the get_readable_path method. New in WebStack 0.10 (Changes since WebStack 0.9) ------------------------------------------------- diff -r 302cc102aaf6 -r 160859a75f44 WebStack/Generic.py --- a/WebStack/Generic.py Fri Aug 19 13:27:38 2005 +0000 +++ b/WebStack/Generic.py Fri Aug 19 20:20:58 2005 +0000 @@ -255,6 +255,21 @@ else: return [value] + # Public utility methods. + + def get_readable_path(self, path, encoding): + + """ + From the given 'path', use the given 'encoding' to decode the information and + convert it to Unicode. Upon success, return the 'path' as a Unicode value. Upon + failure, return None. + """ + + try: + return urllib.unquote(path).decode(encoding) + except UnicodeError: + return None + # Server-related methods. def get_server_name(self):