3. fa.transports

The base transport module contains code that deals with handling transports, as well as the base class that all custom transports should subclass. Transports are implemented as full Django apps, so they may define models, URLs, etc.

class fa.transports.base.TransportBase

The base class for all transports.

3.1. Methods to override in subclasses

TransportBase.__init__(self, name)

All transport subclasses must take the name of the transport as a string as their first argument in the constructor, followed by the entire config dict as keyword args.

Parameters:name (string) – The name of this transport in the settings file.
TransportBase._send(cls, msg)

Override this in TransportBase subclasses to handle actual message sending.

Parameters:msg (fa.models.OutgoingMessage) – The message to send.
TransportBase._send_batch(cls, lst)

Override this in TransportBase subclasses to handle actual batch message sending.

Parameters:lst (list) – The messages to send, as an iterable of fa.models.OutgoingMessage.

3.2. Convenience methods

classmethod TransportBase.get_transport(cls, name)

Returns the instance of the transport with the given configured name.

Parameters:name (string) – The name of this transport in the settings file.
classmethod TransportBase.get_all(cls)

Returns an iterable of all transports in the settings file.

classmethod TransportBase.send(cls, msg)

Sends a single message to the target.

Parameters:msg (fa.models.OutgoingMessage) – The message to send. This method automatically handles forwarding it to the correct transport.
classmethod TransportBase.send_batch(cls, lst)

Sends each OutgoingMessage in lst to its given transport as one or more _send_batch calls.

Parameters:lst (list) – The list of :py:class:`~fa.models.OutgoingMessage`s to send.
classmethod TransportBase.receive(cls, msg)

Called by a transport to process an IncomingMessage from a FoneAstra device. Returns True if an app or device handled the message, False otherwise. Generally only called by custom transports.

Parameters:msg (fa.models.IncomingMessage) – The message coming in from a transport instance.

3.3. Exceptions

exception fa.transports.base.NoTransportException

Thrown whenever a transport is referenced but not set up in the configuration.

Table Of Contents

Previous topic

2. fa.models

Next topic

4. fa.utils

This Page