Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#5303 closed defect (fixed)

Unify default trac.ini and trac.ini.sample contents

Reported by: techtonik <techtonik@…> Owned by: Christian Boos
Priority: normal Milestone: 0.10.5
Component: admin/console Version: 0.10.4
Severity: normal Keywords: config trac.ini.sample
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

After fresh inienv there are two files trac.ini and trac.ini.sample However it is not possible to say if they are the same or not, because the order of entries is not the same - so diff fails to make readable output from it.

http://pastebin.sk/en/1567/

The request is to make trac.ini and trac.ini.sample the same to clarly see the change after Trac upgrade by comparing these two with diff utility.

Attachments (2)

trac.ini (2.3 KB ) - added by techtonik <techtonik@…> 17 years ago.
trac.ini.sample (2.3 KB ) - added by techtonik <techtonik@…> 17 years ago.

Download all attachments as: .zip

Change History (6)

by techtonik <techtonik@…>, 17 years ago

Attachment: trac.ini added

by techtonik <techtonik@…>, 17 years ago

Attachment: trac.ini.sample added

comment:1 by Christian Boos, 17 years ago

Milestone: 0.11

We originally avoided to re-write the trac.ini on purpose, as this would make you loose any comments. But the WebAdmin module is re-writing the trac.ini file anyway, so it's probably not such a big deal.

Also, what changed since the original implementation of the trac.ini.sample is that we now write the trac.ini file ourselves (i.e. not using ConfigParser.write()), so I wonder if there couldn't be an even simpler way to show the defaults.

Would be nice to have for 0.11…

comment:2 by techtonik <techtonik@…>, 17 years ago

Here is a patch for 0.10.4 that is still actual for trunk.

--- site-packages/trac/env_old.py	Wed Apr 11 16:09:24 2007
+++ site-packages/trac/env.py	Sun May 13 20:18:16 2007
@@ -422,20 +422,13 @@
     # Internal methods
 
     def _update_sample_config(self):
-        from ConfigParser import ConfigParser
-        config = ConfigParser()
-        for section, options in self.config.defaults().items():
-            config.add_section(section)
-            for name, value in options.items():
-                config.set(section, name, value)
         filename = os.path.join(self.env.path, 'conf', 'trac.ini.sample')
+        config = Configuration(filename)
+        for section, default_options in config.defaults().iteritems():
+            for name, value in default_options.iteritems():
+                config.set(section, name, value)
         try:
-            fileobj = file(filename, 'w')
-            try:
-                config.write(fileobj)
-                fileobj.close()
-            finally:
-                fileobj.close()
+            config.save()
             self.log.info('Wrote sample configuration file with the new '
                           'settings and their default values: %s',
                           filename)

comment:3 by Christian Boos, 17 years ago

Keywords: config trac.ini.sample added
Milestone: 0.110.10.5
Owner: changed from Christopher Lenz to Christian Boos

Ah, yes, I forgot that the writing of the trac.ini.sample was still done using ConfigParser.write. Using the same method for writing both is then the correct fix. Thanks for the patch which works fine.

comment:4 by Christian Boos, 17 years ago

Resolution: fixed
Status: newclosed

Applied in r5392 (trunk) and r5393 (0.10-stable).

Modify Ticket

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