Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11520 closed defect (fixed)

Some options are not written to trac.ini on environment creation

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 0.12.6
Component: general Version: 1.0-stable
Severity: normal Keywords: config
Cc: Jun Omae Branch:
Release Notes:

Option defaults in trac.web.main were not being written to trac.ini on environment creation.

API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

It appears that the default values for all of the options should be written to trac.ini when the environment is created. However, I noticed that some are missing. Looking at just the [trac] section, the following are missing:

  • default_date_format
  • default_handler
  • default_language
  • default_timezone
  • request_filters
  • use_xsendfile

All of those options are contained in the trac.web.main.RequestDispatcher class.

Attachments (0)

Change History (11)

comment:1 by Jun Omae, 11 years ago

Hmm…. trac.web.main is not declared in [trac.plugins] of setup.py.

  • setup.py

    diff --git a/setup.py b/setup.py
    index d47bebe..1c18629 100755
    a b facilities.  
    141141        trac.versioncontrol.svn_authz = trac.versioncontrol.svn_authz
    142142        trac.versioncontrol.web_ui = trac.versioncontrol.web_ui
    143143        trac.web.auth = trac.web.auth
     144        trac.web.main = trac.web.main
    144145        trac.web.session = trac.web.session
    145146        trac.wiki.admin = trac.wiki.admin
    146147        trac.wiki.interwiki = trac.wiki.interwiki

After the patch:

$ PYTHONPATH=. ~/venv/py25/bin/python setup.py egg_info
$ PYTHONPATH=. ~/venv/py25/bin/python trac/admin/console.py /dev/shm/t11520 initenv project-name sqlite:db/trac.db
$ grep request_filters /dev/shm/t11520/conf/trac.ini
# request_filters = <inherited>

comment:2 by Ryan J Ollos, 11 years ago

Milestone: next-stable-1.0.x1.0.2

You fix the issues faster than I can report them :)

I tried your change and it works well, except I don't see the request_filter entry. I compared all of the other options in trac.ini to what is presented with the TracIni macro and found the following omissions:

  • [logging] log_format
  • [search] default_disabled_filters
  • [sqlite] extensions

The commonality among those 3 options is that the default value is None. Also the default for request_filters is None.

[svn] and [git] sections are missing, but I think that is due to #11437 (components were not enabled when environment was created).

in reply to:  2 comment:3 by Jun Omae, 11 years ago

The commonality among those 3 options is that the default value is None. Also the default for request_filters is None.

[f59bb4f6/jomae.git] would write option-name = instead of # option-name = <inherited> for these options. After the changes, # option-name = <inherited> never be appear in trac.ini even if --inherit option of initenv.

[svn] and [git] sections are missing, but I think that is due to #11437 (components were not enabled when environment was created).

Oh, I hadn't noticed it. [b58247ccb/jomae.git] would fix it. Also see comment of tags/trac-1.0.1/trac/config.py@:158-159#L154 about removing self from set_defaults(self).

comment:4 by Jun Omae, 11 years ago

Cc: Jun Omae added

I found the same issue as #11074 in trac.ini.sample.

$ grep colors conf/trac.ini.sample
graph_colors = ['#cc0', '#0c0', '#0cc', '#00c', '#c0c', '#c00']

comment:5 by Ryan J Ollos, 11 years ago

Thanks for the hints in comment:3. They might be useful for solving #11437. Maybe we can call Configuration.set_defaults() and Configuration.save() when enabling components. If that was done, then it might not be a problem to write the configuration for only the components that are enabled (maybe even preferable since we wouldn't have configuration sections for components that have never been enabled?).

Now I see additionally the [authz_policy], [git] and [svn] sections in trac.ini, as well as the options that were previously missing.

If I define [inherit] file with contents:

[logging]
log_level = DEBUG

pressing Apply changes from the Logging admin page results in the trac.ini file being rewritten with log_level omitted. Looking at the code I'm not sure why the entry is omitted, though the behavior seems fine. I was trying to determine if this code is ever called after your changes: branches/1.0-stable/trac/config.py@12430:251-252#L242.

in reply to:  5 comment:6 by Jun Omae, 11 years ago

Looking at the code I'm not sure why the entry is omitted, though the behavior seems fine. I was trying to determine if this code is ever called after your changes: branches/1.0-stable/trac/config.py@12430:251-252#L242.

Currently (also after the changes), if [inherit] file is used and option's value is equal the inherited value, the option is omitted and # name = <inherited> is not written in trac.ini. That is in Configuration.save() at tags/trac-1.0.1/trac/config.py@:222-224,230#L210.

comment:7 by Ryan J Ollos, 11 years ago

On a default installation, I get the following:

$ trac-admin ../tracdev config get trac default_handler

Error: Option 'default_handler' doesn't exist in section 'trac'

The reason that surprised me is that I thought the default value would be retrieved if the option was not defined in trac.ini.

Anyway, the reason I mention is that the following line should be removed from the changes in [12573] when the changes in this ticket are committed:

        # Remove after change in #11520 is committed
        self._testenv.set_config('trac', 'default_handler',
                                 'WikiModule')

comment:8 by Ryan J Ollos, 11 years ago

I found that if option key was not a unicode string, then # option = <inherited> would still be written to the file if config[section].set('option', None) was called.

I've also pulled in your changes from #11437 and tested. I removed [b58247ccb/jomae.git] after pulling in [ab2c9ca8/jomae.git], since it seems better to only write sections for components that are enabled.

To summarize the proposed behaviors:

  1. Write all options to trac.ini when there is no parent (inherited) file.
  2. Write an empty string when an option value is None.
  3. If option is set in parent file, don't write it to trac.ini.

I'm not sure about (3). Maybe we should stick with the # option = <inherited> notation, but only for options defined in an inherited file (not options that are None).

Latest changes can be found in log:rjollos.git:t11520.2. There may be issues still. Some tests need to be written.

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:9 by Ryan J Ollos, 11 years ago

Description: modified (diff)
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Change from comment:1 committed to 0.12-stable in [12663], merged in [12664:12665]. Related change in [12666:12667].

Other changes will be committed in #11437.

comment:10 by Ryan J Ollos, 11 years ago

Owner: set to Jun Omae

comment:11 by Ryan J Ollos, 11 years ago

Milestone: 1.0.20.12.6

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae 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.