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)
Initialise the resource to serve files from the given 'directory'.
  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')
(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.

respond(self, trans)

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

Generated by Epydoc 2.1 on Fri Jul 22 23:16:52 2005 http://epydoc.sf.net