Package twisted :: Package web :: Module static :: Class File
[frames | no frames]

Class File

              FilePath --+
                         |
Collection --+           |
             |           |
   Constrained --+       |
                 |       |
  ConfigCollection --+   |
                     |   |
              Resource --+
                         |
             Versioned --+
                         |
                        File


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 .
Method Summary
  __init__(self, path, defaultType, ignoredExts, registry, allowExt)
Create a file with the given path.
  createPickleChild(self, name, child)
  createSimilarFile(self, path)
  directoryListing(self)
  getChild(self, path, request)
See twisted.web.Resource.getChild.
  getFileSize(self)
Return file size.
  ignoreExt(self, ext)
Ignore the given extension.
  listEntities(self)
  listNames(self)
  openForReading(self)
Open a file and return it.
  redirect(self, request)
  render(self, request)
You know what you doing.
  upgradeToVersion1(self)
  upgradeToVersion2(self)
  upgradeToVersion3(self)
  upgradeToVersion4(self)
  upgradeToVersion5(self)
  upgradeToVersion6(self)
    Inherited from Resource
  delEntity(self, name)
Remove a static reference for 'name'.
  getChildForRequest(self, request)
(internal) Get a child of mine dependant on a particular request.
  getChildWithDefault(self, path, request)
Retrieve a static or dynamically generated child resource from me.
  getDynamicEntity(self, name, request)
Subclass this to generate an entity on demand.
  getStaticEntity(self, name)
Get an entity that was added to me using putEntity.
  listDynamicEntities(self, request)
A list of all name, entity that I can generate on demand.
  listDynamicNames(self)
Retrieve a list of the names of entities that I store references to.
  listStaticEntities(self)
Retrieve a list of all name, entity pairs that I store references to.
  listStaticNames(self)
Retrieve a list of the names of entities that I store references to.
  putChild(self, path, child)
Register a static child.
  reallyPutEntity(self, name, entity)
    Inherited from ConfigCollection
  entityConstraint(self, entity)
A method that determines whether an entity may be added to me.
  getEntityType(self)
  getNameType(self)
    Inherited from Constrained
  nameConstraint(self, name)
A method that determines whether an entity may be added to me with a given name.
  putEntity(self, name, entity)
Store an entity if it meets both constraints.
    Inherited from Collection
  getEntity(self, name, request)
Retrieve an entity from me.
  removeEntity(self, name, request)
Remove an entity for 'name', based on the content of 'request'.
  storeEntity(self, name, request)
Store an entity for 'name', based on the content of 'request'.
    Inherited from Versioned
  __getstate__(self, dict)
Get state, adding a version number to it on its way out.
  __setstate__(self, state)
  versionUpgrade(self)
(internal) Do a version upgrade.
    Inherited from FilePath
  __repr__(self)
  basename(self)
  child(self, path)
  childSearchPreauth(self, *paths)
Return my first existing child with a name in 'paths'.
  exists(self)
  getatime(self)
  getContent(self)
  getctime(self)
  getmtime(self)
  getsize(self)
  globChildren(self, pattern)
Assuming I am representing a directory, return a list of FilePaths representing my children that match the given pattern.
  isabs(self)
  isdir(self)
  isfile(self)
  islink(self)
  listdir(self)
  makedirs(self)
  open(self, mode)
  preauthChild(self, path)
Use me if `path' might have slashes in it, but you know they're safe.
  remove(self)
  restat(self, reraise)
  setContent(self, content, ext)
  siblingExtension(self, ext)
  siblingExtensionSearch(self, *exts)
Attempt to return a path with my name, given multiple possible extensions.
  splitext(self)
  touch(self)

Class Variable Summary
class __implements__ = twisted.web.resource.IResource
class _directoryLister = twisted.web.woven.dirlist.DirectoryLister
NoResource childNotFound: Resource used to render 404 Not Found error pages.
dict contentEncodings = {'.bz2': 'appliation/x-bzip2', '.gz':...
dict contentTypes = {'.rm': 'audio/x-pn-realaudio', '.obj': '...
list indexNames = ['index', 'index.html', 'index.htm', 'index...
int persistenceVersion = 6                                                                     
dict processors = {}
NoneType type = None                                                                  
    Inherited from Resource
int isLeaf = 0                                                                     
NoneType server = None                                                                  
    Inherited from Versioned
tuple persistenceForgets = ()
    Inherited from FilePath
NoneType statinfo = None                                                                  

Method Details

__init__(self, path, defaultType='text/html', ignoredExts=(), registry=None, allowExt=0)
(Constructor)

Create a file with the given path.
Overrides:
twisted.web.resource.Resource.__init__

getChild(self, path, request)

See twisted.web.Resource.getChild.
Overrides:
twisted.web.resource.Resource.getChild

getFileSize(self)

Return file size.

ignoreExt(self, ext)

Ignore the given extension.

Serve file.ext if file is requested

openForReading(self)

Open a file and return it.

render(self, request)

You know what you doing.
Overrides:
twisted.web.resource.Resource.render

Class Variable Details

childNotFound

Resource used to render 404 Not Found error pages.
Type:
NoResource
Value:
<twisted.web.error.NoResource instance at 0x8548da4>                   

contentEncodings

Type:
dict
Value:
{'.bz2': 'appliation/x-bzip2', '.gz': 'application/x-gzip'}            

contentTypes

Type:
dict
Value:
{'.book': 'application/x-maker',
 '.obj': 'application/octet-stream',
 '.ra': 'audio/x-realaudio',
 '.ras': 'image/x-cmu-raster',
 '.rm': 'audio/x-pn-realaudio',
 '.silo': 'model/mesh',
 '.skd': 'application/x-koan',
 '.skm': 'application/x-koan',
...                                                                    

indexNames

Type:
list
Value:
['index', 'index.html', 'index.htm', 'index.trp', 'index.rpy']         

persistenceVersion

Type:
int
Value:
6                                                                     

processors

Type:
dict
Value:
{}                                                                     

type

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.0 on Sat Sep 13 04:20:55 2003 http://epydoc.sf.net