class documentation

class HTTPFactory(protocol.ServerFactory): (source)

Known subclasses: twisted.web.server.Site

View In Hierarchy

Factory for HTTP server.
Method __init__
Method build​Protocol Create an instance of a subclass of Protocol.
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 _open​Log​File Override in subclasses, e.g. to use twisted.python.logfile.
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 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 __init__(self, logPath=None, timeout=_REQUEST_TIMEOUT, logFormatter=None, reactor=None): (source)
Parameters
log​Path:str or bytesFile path to which access log messages will be written or None to disable logging.
timeout:floatThe initial value of timeOut, which defines the idle connection timeout in seconds, or None to disable the idle timeout.
log​Formatter:IAccessLogFormatter providerAn object to format requests into log lines for the access log. combinedLogFormatter when None is passed.
reactorA IReactorTime provider used to manage connection timeouts and compute logging timestamps.
def buildProtocol(self, addr): (source)

Create an instance of a subclass of Protocol.

The returned instance will handle input on an incoming server connection, and an attribute "factory" pointing to the creating factory.

Alternatively, None may be returned to immediately close the new connection.

Override this method to alter how Protocol instances get created.

Parameters
addran object implementing twisted.internet.interfaces.IAddress
def log(self, request): (source)
Write a line representing request to the access log file.
Parameters
request:RequestThe request object about which to log.
def startFactory(self): (source)
Set up request logging if necessary.
def stopFactory(self): (source)

This will be called before I stop listening on all Ports/Connectors.

This can be overridden to perform 'shutdown' tasks such as disconnecting database connections, closing files, etc.

It will be called, for example, before an application shuts down, if it was connected to a port. User code should not call this function directly.

logFile = (source)

Undocumented

logPath = (source)

Undocumented

timeOut = (source)

Undocumented

def _openLogFile(self, path): (source)
Override in subclasses, e.g. to use twisted.python.logfile.
def _updateLogDateTime(self): (source)
Update log datetime periodically, so we aren't always recalculating it.
_logDateTime: str = (source)
A cached datetime string for log messages, updated by _logDateTimeCall.
_logDateTimeCall: IDelayedCall provided = (source)
A delayed call for the next update to the cached log datetime string.
_logFormatter = (source)
See the logFormatter parameter to __init__
_nativeize = (source)
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.
_reactor = (source)
An IReactorTime provider used to compute logging timestamps.