Components#

Base Classes#

class plinth.app.Component(component_id)[source]#

Interface for an app component.

app_id is a string which is set to the value of the application’s app_id to which this component belongs. It is set when the component is added to an app. When the component is removed from an app, it set to None.

__init__(component_id)[source]#

Initialize the component.

property app#

Return the app this component is part of.

Raises KeyError if this component is not part of any app.

diagnose() list[DiagnosticCheck][source]#

Run diagnostics and return results.

Return value must be a list of results. Each result is a DiagnosticCheck with a unique check_id, a user visible description of the test, the result, test parameters, and the component ID. The test result is a string enumeration from ‘failed’, ‘passed’, ‘error’, ‘warning’ and ‘not_done’.

Also see has_diagnostics().

disable()[source]#

Run operations to disable the component.

enable()[source]#

Run operations to enable the component.

has_diagnostics()[source]#

Return whether at least one diagnostic test is implemented.

If this method return True, the App.has_diagnostics(). also returns True.

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

is_available() bool[source]#

Return whether the app is available to install.

repair(failed_checks: list) bool[source]#

Try to fix failed diagnostics.

The default implementation only requests re-run setup for the app.

Returns whether the app setup should be re-run by the caller.

This method should be overridden by components that implement diagnose(), if there is a known way to fix failed checks. The return value can be changed to False to avoid causing a re-run setup.

failed_checks is a list of DiagnosticChecks related to this component that had failed or warning result.

setup(old_version)[source]#

Run operations to install and configure the component.

uninstall()[source]#

De-configure and uninstall the component.

class plinth.app.LeaderComponent(component_id)[source]#

Interface for an app component that decides the state of the app.

These components determine if the app is enabled or not.

is_enabled()[source]#

Return if the component is enabled.

class plinth.app.FollowerComponent(component_id, is_enabled=False)[source]#

Interface for an app component that follows other components.

These components of the app don’t determine if the app is enabled or not.

__init__(component_id, is_enabled=False)[source]#

Initialize the component.

disable()[source]#

Run operations to disable the component.

enable()[source]#

Run operations to enable the component.

is_enabled()[source]#

Return whether the component is enabled.

set_enabled(enabled)[source]#

Update the internal enabled state of the component.

Other Classes#

class plinth.diagnostic_check.DiagnosticCheck(check_id: str, description: str, result: Result = Result.NOT_DONE, parameters: dict[str, str | int | bool | None]=<factory>, component_id: str | None = None)[source]#

A diagnostic check and optional result and parameters.

__init__(check_id: str, description: str, result: Result = Result.NOT_DONE, parameters: dict[str, str | int | bool | None]=<factory>, component_id: str | None = None) None#
property translated_description#

Return translated string for description.

class plinth.diagnostic_check.Result(*values)[source]#

The result of a diagnostic check.