1.1 --- a/WebStack/Resources/ResourceMap.py Sat Feb 02 23:33:13 2008 +0000
1.2 +++ b/WebStack/Resources/ResourceMap.py Sat Feb 02 23:35:36 2008 +0000
1.3 @@ -26,8 +26,6 @@
1.4
1.5 "A resource mapping names to other resources."
1.6
1.7 - path_encoding = "utf-8"
1.8 -
1.9 def __init__(self, mapping, pass_through=0, directory_redirects=1, path_encoding=None, urlencoding=None):
1.10
1.11 """
1.12 @@ -86,7 +84,7 @@
1.13 self.mapping = mapping
1.14 self.pass_through = pass_through
1.15 self.directory_redirects = directory_redirects
1.16 - self.path_encoding = path_encoding or urlencoding or self.path_encoding
1.17 + self.path_encoding = path_encoding or urlencoding
1.18
1.19 def respond(self, trans):
1.20
1.21 @@ -170,4 +168,19 @@
1.22 query_string = "?" + query_string
1.23 trans.redirect(trans.encode_path(path_without_query, self.path_encoding) + "/" + query_string)
1.24
1.25 +class SimpleMap(MapResource):
1.26 +
1.27 + "A simple mapping of names to resources, focused on the most common case."
1.28 +
1.29 + def __init__(self, mapping, directory_redirects=1):
1.30 +
1.31 + """
1.32 + Initialise the resource with the given 'mapping' and optional
1.33 + 'directory_redirects' settings. Unlike MapResource, other options are
1.34 + not exposed: if the 'mapping' has an entry for None, the 'pass_through'
1.35 + option of MapResource is enabled.
1.36 + """
1.37 +
1.38 + MapResource.__init__(self, mapping, mapping.has_key(None), directory_redirects)
1.39 +
1.40 # vim: tabstop=4 expandtab shiftwidth=4