Ticket #3620: comment_out_globally_set_options-r3717.diff
| File comment_out_globally_set_options-r3717.diff, 2.5 KB (added by cboos, 6 years ago) |
|---|
-
trac/env.py
242 242 if load_defaults: 243 243 for section, default_options in self.config.defaults().iteritems(): 244 244 for name, value in default_options.iteritems(): 245 if self.config.has_site_option(section, name): 246 value = None 245 247 self.config.set(section, name, value) 246 248 247 249 def get_templates_dir(self): -
trac/config.py
162 162 for section, options in sections: 163 163 print>>fileobj, '[%s]' % section 164 164 for key, val in options: 165 print>>fileobj, '%s = %s' % \ 166 (key, to_unicode(val).encode('utf-8')) 165 if key in self[section].overriden: 166 print>>fileobj, '# %s = <set in global trac.ini>' % key 167 else: 168 print>>fileobj, '%s = %s' % \ 169 (key, to_unicode(val).encode('utf-8')) 167 170 print>>fileobj 168 171 finally: 169 172 fileobj.close() … … 183 186 self.parser.read(self.filename) 184 187 self._lastmtime = modtime 185 188 189 def has_site_option(self, section, name): 190 return self.site_parser.has_option(section, name) 186 191 192 187 193 class Section(object): 188 194 """Proxy for a specific configuration section. 189 195 190 196 Objects of this class should not be instantiated directly. 191 197 """ 192 __slots__ = ['config', 'name' ]198 __slots__ = ['config', 'name', 'overriden'] 193 199 194 200 def __init__(self, config, name): 195 201 self.config = config 196 202 self.name = name 203 self.overriden = {} 197 204 198 205 def __contains__(self, name): 199 206 return self.config.parser.has_option(self.name, name) or \ … … 283 290 """ 284 291 if not self.config.parser.has_section(self.name): 285 292 self.config.parser.add_section(self.name) 286 return self.config.parser.set(self.name, name, 287 to_unicode(value).encode('utf-8')) 293 if value is None: 294 self.overriden[name] = True 295 value = '' 296 else: 297 value = to_unicode(value).encode('utf-8') 298 return self.config.parser.set(self.name, name, value) 288 299 289 300 290 301 class Option(object):
