diff options
Diffstat (limited to 'Mailman/initialize.py')
| -rw-r--r-- | Mailman/initialize.py | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/Mailman/initialize.py b/Mailman/initialize.py index 650aa925f..b17e3a9e2 100644 --- a/Mailman/initialize.py +++ b/Mailman/initialize.py @@ -31,9 +31,9 @@ import pkg_resources from zope.interface.verify import verifyObject import Mailman.configuration -import Mailman.ext import Mailman.loginit +from Mailman.app.plugins import get_plugin from Mailman.interfaces import IDatabase @@ -43,7 +43,7 @@ from Mailman.interfaces import IDatabase # initialization, but before database initialization. Generally all other # code will just call initialize(). -def initialize_1(config, propagate_logs): +def initialize_1(config_path, propagate_logs): # By default, set the umask so that only owner and group can read and # write our files. Specifically we must have g+rw and we probably want # o-rwx although I think in most cases it doesn't hurt if other can read @@ -51,48 +51,22 @@ def initialize_1(config, propagate_logs): # restrictive permissions in order to handle private archives, but it # handles that correctly. os.umask(007) - Mailman.configuration.config.load(config) + Mailman.configuration.config.load(config_path) # Create the queue and log directories if they don't already exist. Mailman.configuration.config.ensure_directories_exist() Mailman.loginit.initialize(propagate_logs) - # Set up site extensions directory - Mailman.ext.__path__.append(Mailman.configuration.config.EXT_DIR) def initialize_2(): - # Find all declared entry points in the mailman.database group. There - # must be exactly one or two such entry points defined. If there are two, - # then we remove the one called 'stock' since that's the one that we - # distribute and it's obviously being overridden. If we're still left - # with more than one after we filter out the stock one, it is an error. - entrypoints = list(pkg_resources.iter_entry_points('mailman.database')) - if len(entrypoints) == 0: - raise RuntimeError('No database entry points found') - elif len(entrypoints) == 1: - # Okay, this is the one to use. - entrypoint = entrypoints[0] - elif len(database) == 2: - # Find the one /not/ named 'stock'. - entrypoints = [ep for ep in entrypoints if ep.name <> 'stock'] - if len(entrypoints) == 0: - raise RuntimeError('No database entry points found') - elif len(entrypoints) == 2: - raise RuntimeError('Too many database entry points defined') - else: - assert len(entrypoints) == 1, 'Insanity' - entrypoint = entrypoint[0] - else: - raise RuntimeError('Too many database entry points defined') - # Instantiate the database entry point, ensure that it's of the right - # type, and initialize it. Then stash the object on our configuration - # object. - ep_object = entrypoint.load() - db = ep_object() - verifyObject(IDatabase, db) - db.initialize() - Mailman.configuration.config.db = db + database_plugin = get_plugin('mailman.database') + # Instantiate the database plugin, ensure that it's of the right type, and + # initialize it. Then stash the object on our configuration object. + database = database_plugin() + verifyObject(IDatabase, database) + database.initialize() + Mailman.configuration.config.db = database -def initialize(config=None, propagate_logs=False): - initialize_1(config, propagate_logs) +def initialize(config_path=None, propagate_logs=False): + initialize_1(config_path, propagate_logs) initialize_2() |
