Roundup Tracker - Issues

Issue 2551332

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

Created on 2024-04-14 23:52 by rouilj, last changed 2026-08-24 02:38 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.
msg8500 Author: [hidden] (rouilj) Date: 2026-08-24 02:38
Fixed on: changeset:   8773:29800bbb7c09

One minor nit: when automatic value upgrades occur (number of rounds for
password encryption) the setting is overwritten and not checked
to see if it is set in the DEFAULT section and interpolated.

So:

  [DEFAULT]
  rounds = 250000

  [web]
  password_pbkdf2_default_rounds = %(rounds)s

would have %(rounds)s replaced by an updated number, the value for
rounds would be unchanged.

I can get the DEFAULT section and strip the HOME and other defaults
passed in by
roundup. That lets me recreate the DEFAULT section (except for
interpolations among
values in the DEFAULT section).

There is also a raw=True argument I can use with the config get method
to get the original
uninterpolated line.

It was a matter of storing that raw line with the option and setting up
the updateconfig
to output the raw line when saving the config file in update mode and
output a DEFAULT section.
History
Date User Action Args
2026-08-24 02:38:35rouiljsetstatus: new -> fixed
type: rfe
resolution: fixed
messages: + msg8500
2024-08-29 23:49:17rouiljsetmessages: + msg8123
2024-04-14 23:52:05rouiljcreate