App

class plinth.app.App[source]

Implement common functionality for an app.

An app is composed of components which actually performs various tasks. App itself delegates tasks for individual components. Applications can show a variation their behavior by choosing which components to have and by customizing the components themselves.

‘app_id’ property of the app must string that is a globally unique ID. This is typically also the name of the python module handling the app. So, it should be all lower-case English alphabet and digits without any special characters.

__init__()[source]

Initialize the app object.

add(component)[source]

Add a component to an app.

diagnose()[source]

Run diagnostics and return results.

Return value must be a list of results. Each result is a two-tuple with first value as user visible description of the test followed by the result. The test result is a string enumeration from ‘failed’, ‘passed’ and ‘error’.

Results are typically collected by diagnosing each component of the app and then supplementing the results with any app level diagnostic tests.

Also see has_diagnostics().

disable()[source]

Enable all the components of the app.

enable()[source]

Enable all the components of the app.

classmethod get(app_id)[source]

Return an app with given ID.

get_component(component_id)[source]

Return a component given the component’s ID.

get_components_of_type(component_type)[source]

Return all components of a given type.

has_diagnostics()[source]

Return whether at least one diagnostic test is implemented.

If this method returns True, a button or menu item is shown to the user to run diagnostics on this app. When the action is selected by the user, the diagnose() method is called and the results are presented to the user. Additionally collection of diagnostic results of all apps can be obtained by the user from the Diagnostics module in System section.

If a component of this app implements a diagnostic test, this method returns True.

Further, if a subclass of App overrides the diagnose() method, it is assumed that it is for implementing diagnostic tests and this method returns True for such an app. Override this method if this default behavior does not fit the needs.

property info

Return the information component of the app.

It is mandatory to have one Info component in every app to provide basic information about the app. Trying to access this property without having the Info component will result in a KeyError exception being raised. The lookup for the Info component is performed using the auto-generated component_id assigned to the Info component based on the app_id.

is_enabled()[source]

Return whether all the leader components are enabled.

Return True when there are no leader components.

classmethod list()[source]

Return a list of all apps.

remove(component_id)[source]

Remove a component from the app.

set_enabled(enabled)[source]

Update the status of all follower components.

Do not query or update the status of the leader components.