Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#5135 closed enhancement (duplicate)

Config parse_if_needed() does not handle removing items with multiple processes

Reported by: simon-code@… Owned by: Jonas Borgström
Priority: normal Milestone:
Component: general Version: 0.10.4
Severity: normal Keywords: config
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I run Apache/mod_python, and multiple processes will therefore access, parse and update the environment config settings. For all 'normal' trac.ini settings this works fine - a change for project description, header logo or anything else where an option (or default) already exists. As expected - so far, so good.

I am writing an Admin plugin for creating, updating and deleting ticket custom fields. It works by adding the various config settings, config.save() and then as each process checks the file timestamp it will (hopefully) do a config.parse_if_needed() and reload settings so that each environment gets the new set of custom fields with correct information.

  • Creating works fine. The new options are read and added.
  • Updating works fine. Changing type of existing field, changing sort order, updating default values or options for select.
  • But; Deleting does not work well as it leads to totally random behaviour when reloading my admin page list of custom fields - it all depends on what process displays the page at a given time as they are out of sync.

Research led me to how the config is actually parsed - and especially when it is re-parsed through config.parse_if_needed(). This parser depends on each option having some sort of default value in that it is always able to update a field, but has no way of detecting an existing field in current config that should be completely removed - and no trace remaining. Options in 'ticket-custom' section in an environment configuration can only be removed (or reset) by actually restarting server.

So, I have prepared a patch (config-reparse-with-section-delete.diff). With the ongoing work of the new workflow that also is very dependent on trac.ini files for its behavior, I am sure this is of interest to more config sections than my immediate interest. The patch will completely clear out specific sections before parsing the updated file - ensuring that the current settings as defined in trac.ini will be used.

Attachments (1)

config-reparse-with-section-delete.diff (1007 bytes ) - added by simon-code@… 18 years ago.
Patch for removing specific sections before re-parsing config.

Download all attachments as: .zip

Change History (4)

by simon-code@…, 18 years ago

Patch for removing specific sections before re-parsing config.

comment:1 by simon-code@…, 18 years ago

Keywords: config added

Some of the discussions at #3037 is relevant to this issue - discussing how options should/could be 'removed' in various circumstances.

comment:2 by osimons <simon-code@…>, 18 years ago

Version: 0.10.30.10.4

I have added a patch to #3833 (ticket:3833:env_reload_5342.diff that solves this in a completely different manner - by reloading the environment in the env_cache instead. It is a much better and much more general solution to config updates.

I think my original patch to this ticket (config-reparse-with-section-delete.diff) is the wrong approach - it heads down a path that only serves to complicate, and for instance it will not solve it for other external plugins that adds arbitrary list of options that can be extended and retracted without any 'default' behavior defined using Config options.

comment:3 by Christian Boos, 18 years ago

Resolution: duplicate
Status: newclosed

Superseded by #3833 (and the above mentioned patch)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.