1.1 --- a/WebStack/Resources/Static.py Wed Aug 24 23:42:32 2005 +0000
1.2 +++ b/WebStack/Resources/Static.py Thu Aug 25 13:29:40 2005 +0000
1.3 @@ -27,7 +27,7 @@
1.4
1.5 "A resource serving the contents of a filesystem directory."
1.6
1.7 - def __init__(self, directory, media_types=None, unrecognised_media_type="application/data"):
1.8 + def __init__(self, directory, media_types=None, unrecognised_media_type="application/data", urlencoding=None):
1.9
1.10 """
1.11 Initialise the resource to serve files from the given 'directory'.
1.12 @@ -45,17 +45,22 @@
1.13 Where no media type can be found for a resource, a predefined media
1.14 type is set which can be overridden by specifying a value for the
1.15 optional 'unrecognised_media_type' parameter.
1.16 +
1.17 + The optional 'urlencoding' is used to decode "URL encoded" character
1.18 + values in the request path, and overrides the default encoding wherever
1.19 + possible.
1.20 """
1.21
1.22 self.directory = directory
1.23 self.media_types = media_types or {}
1.24 self.unrecognised_media_type = unrecognised_media_type
1.25 + self.urlencoding = urlencoding
1.26
1.27 def respond(self, trans):
1.28
1.29 "Respond to the given transaction, 'trans', by serving a file."
1.30
1.31 - parts = trans.get_virtual_path_info().split("/")
1.32 + parts = trans.get_virtual_path_info(self.urlencoding).split("/")
1.33 filename = parts[1]
1.34 out = trans.get_response_stream()
1.35