1. fa.apps

The apps module contains classes and functions that deal with FoneAstra apps, which enable a Django app to be discoverable by the FoneAstra framework and facilitate communication between FoneAstra devices and the server.

class fa.apps.FoneAstraApp

This is the core app that all FoneAstra apps should subclass. This class also includes extra methods and fields for interfacing with FoneAstra, and FoneAstra autodiscovery only includes apps that subclass FoneAstraApp.

1.1. Attributes and methods to override in subclasses

FoneAstraApp.app_name

This should be the name of the app. For instance, an application designed for use in a milk bank should set app_name to “Milk Bank” in its subclass.

Example:

app_name = "Milk Bank"
FoneAstraApp.app_index

The app’s index view, as a reverse name. Override this in subclasses.

Example:

app_index = "mb_index"
FoneAstraApp.device_types

An iterable of class objects in this app that subclass FoneAstraDevice. Only devices with their type listed in this iterable will have their instance receive method called when they send a message to the server.

Example:

from mb.models import MilkBankDevice
device_types = (MilkBankDevice,)
classmethod FoneAstraApp.receive(cls, msg)

This method gets called if a message arrives that did not come from any registered FoneAstra device in any app. This method is most frequently called for configuration messages.

Parameters:msg (fa.models.IncomingMessage) – The incoming message.

1.2. Convenience methods

classmethod FoneAstraApp.find_all_fa_apps(cls)

Returns all FoneAstraApp subclasses defined in all apps in INSTALLED_APPS.

classmethod FoneAstraApp.get_device(cls, phone_number)

Returns the FoneAstra device with the given phone number and with a type contained in device_types, or None if no such device exists.

Parameters:phone_number (string) – The phone number corresponding to the device.

Table Of Contents

Previous topic

3. Module Reference

Next topic

2. fa.models

This Page