mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Make setup method part of App class for all apps
- Primary purpose is to complete the App API and allow for multiple apps to be present in a module without a single clashing setup() method. Secondary objective is to get rid of SetupHelper instance simple use App instance instead. - This brings us closer to not needing to implement setup() method for some of the typical apps. - Remove default value None for old_version parameter. - A valid integer value is always passed to this call. - The value of None is undefined. - Simplifies the App API slightly. - Drop setting 'pre', 'post' values to indicate the stage of setup for the App. - Simplifies the setup methods significantly. Eliminates a class of bugs (some of them seen earlier). - The UI can show a simple 'installing...' or progress spinner instead of individual stages. - There are currently many inconsistencies where many operations are not wrapped in helper.call() calls. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
cbef3e0163
commit
75f6abac1e
55 files changed
+505
-553
No files matched your search
+20
-15
@@ -9,28 +9,33 @@ Installing packages required for the app
|
||||
So far, we haven't dealt with installing the packages needed for Transmission to
|
||||
work. Nor did we take care of performing the initial configuration for
|
||||
Transmission. FreedomBox takes care of installing all the Debian packages
|
||||
required for our app to work. All we need to do is specify the list of the
|
||||
Debian packages required in the ``setup()`` method that is called during
|
||||
installation:
|
||||
required for our app to work. All we need to do is call the base class method in
|
||||
the ``setup()`` method that of the ``TrasmissionApp`` class that is called
|
||||
during installation. The base class ``setup()`` method in turn calls ``setup()``
|
||||
on the ``Packages`` component which performs the actual installation:
|
||||
|
||||
.. code-block:: python3
|
||||
:caption: ``__init__.py``
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
app.setup(old_version)
|
||||
class TransmissionApp(app_module.App):
|
||||
...
|
||||
|
||||
new_configuration = {
|
||||
'rpc-whitelist-enabled': False,
|
||||
'rpc-authentication-required': False
|
||||
}
|
||||
helper.call('post', privileged.merge_configuration, new_configuration)
|
||||
helper.call('post', app.enable)
|
||||
def setup(self, old_version):
|
||||
"""Install and configure the app."""
|
||||
super().setup(old_version)
|
||||
|
||||
new_configuration = {
|
||||
'rpc-whitelist-enabled': False,
|
||||
'rpc-authentication-required': False
|
||||
}
|
||||
privileged.merge_configuration(new_configuration)
|
||||
|
||||
self.enable()
|
||||
|
||||
The first time this app's view is accessed, FreedomBox shows an app installation
|
||||
page and allows the user to install the app. After the app installation is
|
||||
completed, the user is shown the app's configuration page.
|
||||
|
||||
In case of our app Transmission, first we are installing the Debian packages,
|
||||
then performing the first time configuration on the app using the action script
|
||||
and finally enabling the app.
|
||||
In case of our app Transmission, first we are installing the Debian packages (by
|
||||
calling base class ``setup()`` method), then performing the first time
|
||||
configuration on the app using the action script and finally enabling the app.
|
||||
Reference in new issue
Block a user