May 2018
Beginner to intermediate
452 pages
11h 26m
English
As with any kind of data persistence, we need to start by implementing a model. As with our CSVModel class, the settings model needs to save and load the data, as well as define the layout of the settings data.
In the models.py file, let's start a new class as follows:
class SettingsModel:
"""A model for saving settings"""
Just as we did with our CSVModel class, we'll need to define our model's schema:
variables = {
'autofill date': {'type': 'bool', 'value': True},
'autofill sheet data': {'type': 'bool', 'value': True}
}
The variables dictionary will store both the schema and the values for each item. Each setting has a dictionary listing the data type and default value (we could list other attributes ...
Read now
Unlock full access