diff --git a/trac/admin/tests/console.py b/trac/admin/tests/console.py
|
a
|
b
|
|
| 70 | 70 | self._db = InMemoryDatabase() |
| 71 | 71 | return self._db |
| 72 | 72 | |
| 73 | | def create(self, db_str=None): |
| 74 | | pass |
| | 73 | def create(self, options=[]): |
| | 74 | self.setup_config() |
| 75 | 75 | |
| 76 | 76 | def verify(self): |
| 77 | 77 | return True |
| … |
… |
|
| 84 | 84 | return cls.__module__.startswith('trac.') and \ |
| 85 | 85 | cls.__module__.find('.tests.') == -1 |
| 86 | 86 | |
| 87 | | def setup_config(self, load_defaults=None): |
| | 87 | def setup_config(self): |
| 88 | 88 | self.config = InMemoryConfiguration(None) |
| | 89 | self.setup_log() |
| 89 | 90 | |
| 90 | 91 | |
| 91 | 92 | class TracadminTestCase(unittest.TestCase): |
diff --git a/trac/config.py b/trac/config.py
|
a
|
b
|
|
| 286 | 286 | and os.access(self.filename, os.W_OK): |
| 287 | 287 | os.utime(self.filename, None) |
| 288 | 288 | |
| | 289 | def set_defaults(self, compmgr=None): |
| | 290 | """Retrieve all default values and store them explicitly in the |
| | 291 | configuration, so that they can be saved to file. |
| | 292 | |
| | 293 | Values already set in the configuration are not overridden. |
| | 294 | """ |
| | 295 | for section, default_options in self.defaults(compmgr).items(): |
| | 296 | for name, value in default_options.items(): |
| | 297 | if not self.parser.has_option(_to_utf8(section), |
| | 298 | _to_utf8(name)): |
| | 299 | if any(parent[section].contains(name, defaults=False) |
| | 300 | for parent in self.parents): |
| | 301 | value = None |
| | 302 | self.set(section, name, value) |
| | 303 | |
| 289 | 304 | |
| 290 | 305 | class Section(object): |
| 291 | 306 | """Proxy for a specific configuration section. |
diff --git a/trac/env.py b/trac/env.py
|
a
|
b
|
|
| 204 | 204 | ComponentManager.__init__(self) |
| 205 | 205 | |
| 206 | 206 | self.path = path |
| 207 | | self.setup_config(load_defaults=create) |
| 208 | | self.setup_log() |
| 209 | | |
| 210 | 207 | self.systeminfo = [] |
| 211 | | from trac import core, __version__ as VERSION |
| 212 | | self.log.info('-' * 32 + ' environment startup [Trac %s] ' + '-' * 32, |
| 213 | | get_pkginfo(core).get('version', VERSION)) |
| 214 | 208 | self._href = self._abs_href = None |
| 215 | 209 | |
| 216 | | from trac.loader import load_components |
| 217 | | plugins_dir = self.shared_plugins_dir |
| 218 | | load_components(self, plugins_dir and (plugins_dir,)) |
| 219 | | |
| 220 | 210 | if create: |
| 221 | 211 | self.create(options) |
| 222 | 212 | else: |
| 223 | 213 | self.verify() |
| | 214 | self.setup_config() |
| 224 | 215 | |
| 225 | 216 | if create: |
| 226 | 217 | for setup_participant in self.setup_participants: |
| … |
… |
|
| 393 | 384 | |
| 394 | 385 | # Setup the default configuration |
| 395 | 386 | os.mkdir(os.path.join(self.path, 'conf')) |
| 396 | | create_file(os.path.join(self.path, 'conf', 'trac.ini')) |
| 397 | 387 | create_file(os.path.join(self.path, 'conf', 'trac.ini.sample')) |
| 398 | | skip_defaults = any((section, option) == ('inherit', 'file') |
| 399 | | for section, option, value in options) |
| 400 | | self.setup_config(load_defaults=not skip_defaults) |
| | 388 | config = Configuration(os.path.join(self.path, 'conf', 'trac.ini')) |
| 401 | 389 | for section, name, value in options: |
| 402 | | self.config.set(section, name, value) |
| 403 | | self.config.save() |
| 404 | | # Full reload to get 'inherit' working |
| 405 | | self.config.parse_if_needed(force=True) |
| 406 | | del self._rules |
| | 390 | config.set(section, name, value) |
| | 391 | config.save() |
| | 392 | self.setup_config() |
| | 393 | if not any((section, option) == ('inherit', 'file') |
| | 394 | for section, option, value in options): |
| | 395 | self.config.set_defaults(self) |
| | 396 | self.config.save() |
| 407 | 397 | |
| 408 | 398 | # Create the database |
| 409 | 399 | DatabaseManager(self).init_db() |
| … |
… |
|
| 427 | 417 | row = cursor.fetchone() |
| 428 | 418 | return row and int(row[0]) |
| 429 | 419 | |
| 430 | | def setup_config(self, load_defaults=False): |
| | 420 | def setup_config(self): |
| 431 | 421 | """Load the configuration file.""" |
| 432 | 422 | self.config = Configuration(os.path.join(self.path, 'conf', |
| 433 | 423 | 'trac.ini')) |
| 434 | | if load_defaults: |
| 435 | | for section, default_options in self.config.defaults(self).items(): |
| 436 | | for name, value in default_options.items(): |
| 437 | | if any(parent[section].contains(name, defaults=False) |
| 438 | | for parent in self.config.parents): |
| 439 | | value = None |
| 440 | | self.config.set(section, name, value) |
| | 424 | self.setup_log() |
| | 425 | from trac.loader import load_components |
| | 426 | plugins_dir = self.shared_plugins_dir |
| | 427 | load_components(self, plugins_dir and (plugins_dir,)) |
| 441 | 428 | |
| 442 | 429 | def get_templates_dir(self): |
| 443 | 430 | """Return absolute path to the templates directory.""" |
| … |
… |
|
| 466 | 453 | .replace('%(project)s', self.project_name) |
| 467 | 454 | self.log, self._log_handler = logger_handler_factory( |
| 468 | 455 | logtype, logfile, self.log_level, self.path, format=format) |
| | 456 | from trac import core, __version__ as VERSION |
| | 457 | self.log.info('-' * 32 + ' environment startup [Trac %s] ' + '-' * 32, |
| | 458 | get_pkginfo(core).get('version', VERSION)) |
| 469 | 459 | |
| 470 | 460 | def get_known_users(self, cnx=None): |
| 471 | 461 | """Generator that yields information about all known users, i.e. users |