Roundup Tracker - Issues

Issue 2551332

classification
roundup-admin updateconfig does not preserve DEFAULT section or interpolation tokens
Type: Severity: normal
Components: Command-line interface Versions:
process
Status: new
:
: : rouilj
Priority: :

Created on 2024-04-14 23:52 by rouilj, last changed 2024-08-29 23:49 by rouilj.

Messages
msg7984 Author: [hidden] (rouilj) Date: 2024-04-14 23:52
The standard Python configparser allows the following in config.ini:

   [DEFAULT]
   local_admin_email = admin@example.com

   [main]
   admin_email = %(local_admin_email)s

It can be useful to collect all the localized changes at the top to make
updating them (or seeing how things differ from the default) easier.
However when upgrading roundup using the updateconfig command to roundup-admin,
the new config file does not preserve the DEFAULT section. Also interpolation
tokens (e.g. %(local_admin_email)s are replaced with their values
(admin@example.com).

Adding interpolation=None to

        config = configparser.ConfigParser(config_defaults, interpolation=None)

in configuration.py:Config::load_ini does prevent the interpolation of the tokens.

A call to config.defaults() includes config_defaults plus the settings in the
DEFAULT section of config.ini. So we could add a self.ini_defaults to store
the dict we get from config.defaults() minus the settings in config_defaults.
Then this could be written as the DEFAULT section if self.ini_defaults is true
(has keys).

We also need to pass interpolation=None down from the call in admin.py::do_genconfig()
for the case where update is true.

If this is done, do_updateconfig should probably not call do_genconfig anymore. The
code for handling updates and warning when settings change is larger than the
original do_genconfig() code. Also we need to consider what happens if some of the
warning checks get an interpolation token rather than the actual data.

Sigh this is getting tricky. Maybe this is YAGNI?
msg8123 Author: [hidden] (rouilj) Date: 2024-08-29 23:49
Another issue, the values for all the settings are validated. If the value
uses interpolation, it may not pass validation when interpolation is disabled.

So some method of disabling the validation code is needed to allow updateconfig
to handle the un-interpolated strings.
History
Date User Action Args
2024-08-29 23:49:17rouiljsetmessages: + msg8123
2024-04-14 23:52:05rouiljcreate