class documentation

class XmlStream(protocol.Protocol, utility.EventDispatcher): (source)

Known subclasses: twisted.words.protocols.jabber.xmlstream.XmlStream

View In Hierarchy

Generic Streaming XML protocol handler.

This protocol handler will parse incoming data as XML and dispatch events accordingly. Incoming stanzas can be handled by registering observers using XPath-like expressions that are matched against each stanza. See utility.EventDispatcher for details.

Method __init__ Undocumented
Method connection​Lost Called when the connection is shut down.
Method connection​Made Called when a connection is made.
Method data​Received Called whenever data is received.
Method on​Document​End Called whenever the end tag of the root element has been received.
Method on​Document​Start Called whenever the start tag of a root element has been received.
Method on​Element Called whenever a direct child element of the root element has been received.
Method reset​Dispatch​Fn Set the default function (onElement) to handle elements.
Method send Send data over the stream.
Method set​Dispatch​Fn Set another function to handle elements.
Instance Variable raw​Data​In​Fn Undocumented
Instance Variable raw​Data​Out​Fn Undocumented
Instance Variable stream Undocumented
Method _initialize​Stream Sets up XML Parser.

Inherited from Protocol:

Method log​Prefix Return a prefix matching the class name, to identify log messages related to this protocol instance.
Class Variable factory Undocumented

Inherited from BaseProtocol (via Protocol):

Method make​Connection Make a connection to a transport and a server.
Instance Variable connected Undocumented
Instance Variable transport Undocumented

Inherited from EventDispatcher:

Method add​Observer Register an observer for an event.
Method add​Onetime​Observer Register a one-time observer for an event.
Method dispatch Dispatch an event.
Method remove​Observer Remove callable as observer for an event.
Instance Variable prefix Undocumented
Method _add​Observer Undocumented
Method _get​Event​And​Observers Undocumented
Instance Variable _dispatch​Depth Undocumented
Instance Variable _event​Observers Undocumented
Instance Variable _update​Queue Undocumented
Instance Variable _xpath​Observers Undocumented
def connectionLost(self, reason): (source)

Called when the connection is shut down.

Dispatches the STREAM_END_EVENT.

def connectionMade(self): (source)

Called when a connection is made.

Sets up the XML parser and dispatches the STREAM_CONNECTED_EVENT event indicating the connection has been established.

def dataReceived(self, data): (source)

Called whenever data is received.

Passes the data to the XML parser. This can result in calls to the DOM handlers. If a parse error occurs, the STREAM_ERROR_EVENT event is called to allow for cleanup actions, followed by dropping the connection.

def onDocumentEnd(self): (source)

Called whenever the end tag of the root element has been received.

Closes the connection. This causes connectionLost being called.

def onDocumentStart(self, rootElement): (source)

Called whenever the start tag of a root element has been received.

Dispatches the STREAM_START_EVENT.

def onElement(self, element): (source)

Called whenever a direct child element of the root element has been received.

Dispatches the received element.

def resetDispatchFn(self): (source)
Set the default function (onElement) to handle elements.
def send(self, obj): (source)

Send data over the stream.

Sends the given obj over the connection. obj may be instances of domish.Element, unicode and str. The first two will be properly serialized and/or encoded. str objects must be in UTF-8 encoding.

Note: because it is easy to make mistakes in maintaining a properly encoded str object, it is advised to use unicode objects everywhere when dealing with XML Streams.

Parameters
obj:domish.Element, domish or strObject to be sent over the stream.
def setDispatchFn(self, fn): (source)
Set another function to handle elements.
rawDataInFn = (source)

Undocumented

rawDataOutFn = (source)

Undocumented

stream = (source)

Undocumented

def _initializeStream(self): (source)
Sets up XML Parser.