Package WebStack :: Package Resources :: Module Static :: Class DirectoryResource
[show private | hide private]
[frames | no frames]

Class DirectoryResource


A resource serving the contents of a filesystem directory.
Method Summary
  __init__(self, directory, media_types, unrecognised_media_type, urlencoding)
Initialise the resource to serve files from the given 'directory'.
  not_found(self, trans, filename)
Send the "not found" response using the given transaction, 'trans', and specifying the given 'filename' (if appropriate).
  respond(self, trans)
Respond to the given transaction, 'trans', by serving a file.

Method Details

__init__(self, directory, media_types=None, unrecognised_media_type='application/data', urlencoding='utf-8')
(Constructor)

Initialise the resource to serve files from the given 'directory'.

The optional 'media_types' dictionary can be used to map filename extensions to media types, where extensions consist of the part of a name after a "." character (such as "txt", "html"), and where media types are the usual content descriptions (such as "text/plain" and "text/html").

If 'media_types' contains a mapping from None to a media type, then this mapping is used when no extension is present on a requested resource name.

Where no media type can be found for a resource, a predefined media type is set which can be overridden by specifying a value for the optional 'unrecognised_media_type' parameter.

The optional 'urlencoding' is used to decode "URL encoded" character values in the request path, and overrides the default encoding wherever possible.

not_found(self, trans, filename)

Send the "not found" response using the given transaction, 'trans', and specifying the given 'filename' (if appropriate).

respond(self, trans)

Respond to the given transaction, 'trans', by serving a file.

Generated by Epydoc 2.1 on Sat Nov 26 02:16:40 2005 http://epydoc.sf.net