twisted :: web :: server :: Site :: Class Site
[hide private]

classobj Site

  internet.protocol.Factory --+        
                              |        
internet.protocol.ServerFactory --+    
                                  |    
                   http.HTTPFactory --+
                                      |
                                     Site
Known Subclasses:

A web site: manage log, sessions, and resources.

Instance Methods [hide private]
 
__getstate__(self)
 
__init__(self, resource, requestFactory=None, *args, **kwargs)
 
__provides__(...)
Special descriptor for class __provides__
str
_entropy(n)
Return n random bytes suitable for cryptographic use.
 
_mkuid(self)
(internal) Generate an opaque, unique ID for a user's session.
 
_openLogFile(self, path)
Override in subclasses, e.g.
 
acceptableProtocols(self)
Protocols this server can speak.
 
buildProtocol(self, addr)
Generate a channel attached to this site.
 
getChildWithDefault(self, pathEl, request)
Emulate a resource's getChild method.
 
getResourceFor(self, request)
Get a resource for a request.
 
getSession(self, uid)
Get a previously generated session.
 
makeSession(self)
Generate a new Session instance, and store it for future reference.
 
render(self, request)
Redirect because a Site is always a directory.

Inherited from http.HTTPFactory: log, protocol, startFactory, stopFactory

Inherited from http.HTTPFactory (private): _updateLogDateTime

Inherited from internet.protocol.Factory: __providedBy__, doStart, doStop, logPrefix

Class Methods [hide private]

Inherited from internet.protocol.Factory: forProtocol

Class Variables [hide private]
  __implemented__ = <implementedBy twisted.web.server.Site>
  isLeaf = 0

Inherited from http.HTTPFactory: logPath, timeOut

Inherited from internet.protocol.Factory: noisy, numPorts

Instance Variables [hide private]
  counter = 0
increment value used for generating unique sessions ID.
  displayTracebacks = True
if set, Twisted internal errors are displayed on rendered pages.
requestFactory
A factory which is called with (channel) and creates Request instances.
  sessionCheckTime = 1800
Deprecated.
sessionFactory
factory for sessions objects.

Inherited from http.HTTPFactory (private): _logDateTime, _logDateTimeCall, _logFormatter, _nativeize, _reactor

Method Details [hide private]

__init__(self, resource, requestFactory=None, *args, **kwargs)
(Constructor)

 
Parameters:
  • resource (IResource provider) - The root of the resource hierarchy. All request traversal for requests received by this factory will begin at this resource.
  • requestFactory (callable or class.) - Overwrite for default requestFactory.
Overrides: http.HTTPFactory.__init__

See Also: twisted.web.http.HTTPFactory.__init__

__provides__(...)

 
Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that
we can get declarations for objects without instance-specific
interfaces a bit quicker.

Overrides: internet.protocol.Factory.__provides__

_openLogFile(self, path)

 

Override in subclasses, e.g. to use twisted.python.logfile.

Overrides: http.HTTPFactory._openLogFile
(inherited documentation)

buildProtocol(self, addr)

 

Generate a channel attached to this site.

Parameters:
  • addr - an object implementing twisted.internet.interfaces.IAddress
Overrides: internet.protocol.Factory.buildProtocol

getResourceFor(self, request)

 

Get a resource for a request.

This iterates through the resource hierarchy, calling getChildWithDefault on each resource it finds for a path element, stopping when it hits an element where isLeaf is true.

getSession(self, uid)

 

Get a previously generated session.

Parameters:
  • uid (bytes.) - Unique ID of the session.

Instance Variable Details [hide private]

displayTracebacks

if set, Twisted internal errors are displayed on rendered pages. Default to True.
Value:
True

requestFactory

A factory which is called with (channel) and creates Request instances. Default to Request.
Value:
twisted.web.server.Request

sessionCheckTime

Deprecated. See Session.sessionTimeout instead.
Value:
1800

sessionFactory

factory for sessions objects. Default to Session.
Value:
twisted.web.server.Session