~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/config/__init__.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-26 04:36:33 UTC
  • mfrom: (14022.4.6 dbconfig-section-doom)
  • Revision ID: launchpad@pqm.canonical.com-20110926043633-bqcr5e4eeev57o5s
[r=lifeless][no-qa] Drop DatabaseConfig's obsolete section selection
        support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
 
33
33
__all__ = [
34
 
    'DatabaseConfig',
35
34
    'dbconfig',
36
35
    'config',
37
36
    ]
461
460
    def reset(self):
462
461
        self.overrides = DatabaseConfigOverrides()
463
462
 
464
 
    def setConfigSection(self, section_name):
465
 
        self._config_section = section_name
466
 
 
467
 
    def getSectionName(self):
468
 
        """The name of the config file section this DatabaseConfig references.
469
 
        """
470
 
        return self._config_section
471
 
 
472
463
    def _getConfigSections(self):
473
464
        """Returns a list of sections to search for database configuration.
474
465
 
475
466
        The first section in the list has highest priority.
476
467
        """
477
 
        if self._config_section is None:
478
 
            return [config.database]
479
 
        overlay = config
480
 
        for part in self._config_section.split('.'):
481
 
            overlay = getattr(overlay, part)
482
 
        return [self.overrides, overlay, config.database]
 
468
        # config.launchpad remains here for compatibility -- production
 
469
        # appserver configs customise its dbuser. Eventually they should
 
470
        # be migrated into config.database, and this can be removed.
 
471
        return [self.overrides, config.launchpad, config.database]
483
472
 
484
473
    def __getattr__(self, name):
485
474
        sections = self._getConfigSections()
497
486
 
498
487
 
499
488
dbconfig = DatabaseConfig()
500
 
dbconfig.setConfigSection('launchpad')