class documentation

class Site(http.HTTPFactory): (source)

Implements interfaces: twisted.internet.interfaces.IProtocolNegotiationFactory

View In Hierarchy

A web site: manage log, sessions, and resources.
Method __getstate__ Undocumented
Method __init__ No summary
Method acceptable​Protocols Protocols this server can speak.
Method build​Protocol Generate a channel attached to this site.
Method get​Child​With​Default Emulate a resource's getChild method.
Method get​Resource​For Get a resource for a request.
Method get​Session Get a previously generated session.
Method make​Session Generate a new Session instance, and store it for future reference.
Method render Redirect because a Site is always a directory.
Class Variable is​Leaf Undocumented
Instance Variable counter increment value used for generating unique sessions ID.
Instance Variable display​Tracebacks If set, unhandled exceptions raised during rendering are returned to the client as HTML. Default to False.
Instance Variable request​Factory A factory which is called with (channel) and creates Request instances. Default to Request.
Instance Variable resource Undocumented
Instance Variable session​Check​Time Deprecated. See Session.sessionTimeout instead.
Instance Variable session​Factory factory for sessions objects. Default to Session.
Instance Variable sessions Undocumented
Method _mkuid (internal) Generate an opaque, unique ID for a user's session.
Method _open​Log​File Override in subclasses, e.g. to use twisted.python.logfile.

Inherited from HTTPFactory:

Method log Write a line representing request to the access log file.
Method start​Factory Set up request logging if necessary.
Method stop​Factory This will be called before I stop listening on all Ports/Connectors.
Instance Variable log​File Undocumented
Instance Variable log​Path Undocumented
Instance Variable time​Out Undocumented
Method _update​Log​Date​Time Update log datetime periodically, so we aren't always recalculating it.
Instance Variable _log​Date​Time A cached datetime string for log messages, updated by _logDateTimeCall.
Instance Variable _log​Date​Time​Call A delayed call for the next update to the cached log datetime string.
Instance Variable _log​Formatter See the logFormatter parameter to __init__
Instance Variable _nativeize A flag that indicates whether the log file being written to wants native strings (True) or bytes (False). This is only to support writing to twisted.python.log which, unfortunately, works with native strings.
Instance Variable _reactor An IReactorTime provider used to compute logging timestamps.

Inherited from Factory (via HTTPFactory, ServerFactory):

Class Method for​Protocol Create a factory for the given protocol.
Method do​Start Make sure startFactory is called.
Method do​Stop Make sure stopFactory is called.
Method log​Prefix Describe this factory for log messages.
Class Variable noisy Undocumented
Class Variable protocol Undocumented
Instance Variable num​Ports Undocumented
def __getstate__(self): (source)

Undocumented

def __init__(self, resource, requestFactory=None, *args, **kwargs): (source)
Parameters
resource:IResource providerThe root of the resource hierarchy. All request traversal for requests received by this factory will begin at this resource.
request​Factory:callable or class.Overwrite for default requestFactory.
*argsUndocumented
**kwargsUndocumented
See Also
twisted.web.http.HTTPFactory.__init__
def acceptableProtocols(self): (source)
Protocols this server can speak.
def buildProtocol(self, addr): (source)
Generate a channel attached to this site.
def getChildWithDefault(self, pathEl, request): (source)
Emulate a resource's getChild method.
def getResourceFor(self, request): (source)

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.

def getSession(self, uid): (source)
Get a previously generated session.
Parameters
uid:bytes.Unique ID of the session.
Raises
KeyErrorIf the session is not found.
def makeSession(self): (source)
Generate a new Session instance, and store it for future reference.
def render(self, request): (source)
Redirect because a Site is always a directory.
isLeaf: int = (source)

Undocumented

counter = (source)
increment value used for generating unique sessions ID.
displayTracebacks: bool = (source)
If set, unhandled exceptions raised during rendering are returned to the client as HTML. Default to False.
requestFactory = (source)
A factory which is called with (channel) and creates Request instances. Default to Request.
resource = (source)

Undocumented

sessionCheckTime: int = (source)
Deprecated. See Session.sessionTimeout instead.
sessionFactory = (source)
factory for sessions objects. Default to Session.
sessions: dict = (source)

Undocumented

def _mkuid(self): (source)
(internal) Generate an opaque, unique ID for a user's session.
def _openLogFile(self, path): (source)
Override in subclasses, e.g. to use twisted.python.logfile.