Class t.w.s.File(StaticRenderMixin):

Part of twisted.web2.static View Source View In Hierarchy

Known subclasses: twisted.web2.dav.static.DAVFile

Implements interfaces: twisted.web2.iweb.IResource

File is a resource that represents a plain non-interpreted file (although it can look for an extension like .rpy or .cgi and hand the file to a processor for interpretation if you wish). Its constructor takes a file path.

Alternatively, you can give a directory path to the constructor. In this case the resource will represent that directory, and its children will be files underneath that directory. This provides access to an entire filesystem tree with a single Resource.

If you map the URL 'http://server/FILE' to a resource created as File('/tmp'), then http://server/FILE/ will return an HTML-formatted listing of the /tmp/ directory, and http://server/FILE/foo/bar.html will return the contents of /tmp/foo/bar.html .
Line # Kind Name Docs
173 Method _getContentTypes Undocumented
191 Method __init__ Create a file with the given path.
210 Method exists
213 Method etag
230 Method lastModified
236 Method creationDate
242 Method contentLength
253 Method _initTypeAndEncoding Undocumented
264 Method contentType
269 Method contentEncoding
274 Method displayName
280 Method ignoreExt Ignore the given extension.
287 Method directoryListing Undocumented
294 Method putChild Register a child with the given name with this resource.
302 Method getChild Look up a child resource.
319 Method listChildren
328 Method locateChild See IResource.locateChild.
367 Method renderHTTP Return an IResponse or a deferred which will fire an
371 Method render You know what you doing.
419 Method createSimilarFile Undocumented

Inherited from StaticRenderMixin:

Line # Kind Name Docs
77 Method checkPreconditions Undocumented

Inherited from RenderMixin (via StaticRenderMixin):

Line # Kind Name Docs
19 Method allowedMethods
89 Method http_OPTIONS Respond to a OPTIONS request.
99 Method http_TRACE Respond to a TRACE request.
107 Method http_HEAD Respond to a HEAD request.
115 Method http_GET Respond to a GET request.
def _getContentTypes(self):
Undocumented
def __init__(self, path, defaultType='text/plain', ignoredExts=(), processors=None, indexNames=None):
Create a file with the given path.
def exists(self):
ReturnsTrue if the resource exists on the server, False otherwise.
def etag(self):
ReturnsThe current etag for the resource if available, None otherwise.
def lastModified(self):
ReturnsThe last modified time of the resource if available, None otherwise.
def creationDate(self):
ReturnsThe creation date of the resource if available, None otherwise.
def contentLength(self):
ReturnsThe size in bytes of the resource if available, None otherwise.
def _initTypeAndEncoding(self):
Undocumented
def contentType(self):
ReturnsThe MIME type of the resource if available, None otherwise.
def contentEncoding(self):
ReturnsThe encoding of the resource if available, None otherwise.
def displayName(self):
ReturnsThe display name of the resource if available, None otherwise.
def ignoreExt(self, ext):

Ignore the given extension.

Serve file.ext if file is requested
def directoryListing(self):
Undocumented
def putChild(self, name, child):
Register a child with the given name with this resource.
Parametersnamethe name of the child (a URI path segment)
childthe child to register
def getChild(self, name):
Look up a child resource.
Returnsthe child of this resource with the given name.
def listChildren(self):
Returnsa sequence of the names of all known children of this resource.
def locateChild(self, req, segments):
See IResource.locateChild.
def renderHTTP(self, req):
Return an IResponse or a deferred which will fire an IResponse. This response will be written to the web browser which initiated the request.
def render(self, req):
You know what you doing.
def createSimilarFile(self, path):
Undocumented