55
59
Mailman.loginit.initialize(propagate_logs)
56
60
# Set up site extensions directory
57
61
Mailman.ext.__path__.append(Mailman.configuration.config.EXT_DIR)
58
# Initialize the IListManager, IMemberManager, and IMessageManager
59
modparts = Mailman.configuration.config.MANAGERS_INIT_FUNCTION.split(DOT)
60
funcname = modparts.pop()
61
modname = DOT.join(modparts)
63
initfunc = getattr(sys.modules[modname], funcname)
67
64
def initialize_2():
68
Mailman.database.initialize()
65
# Find all declared entry points in the mailman.database group. There
66
# must be exactly one or two such entry points defined. If there are two,
67
# then we remove the one called 'stock' since that's the one that we
68
# distribute and it's obviously being overridden. If we're still left
69
# with more than one after we filter out the stock one, it is an error.
70
entrypoints = list(pkg_resources.iter_entry_points('mailman.database'))
71
if len(entrypoints) == 0:
72
raise RuntimeError('No database entry points found')
73
elif len(entrypoints) == 1:
74
# Okay, this is the one to use.
75
entrypoint = entrypoints[0]
76
elif len(database) == 2:
77
# Find the one /not/ named 'stock'.
78
entrypoints = [ep for ep in entrypoints if ep.name <> 'stock']
79
if len(entrypoints) == 0:
80
raise RuntimeError('No database entry points found')
81
elif len(entrypoints) == 2:
82
raise RuntimeError('Too many database entry points defined')
84
assert len(entrypoints) == 1, 'Insanity'
85
entrypoint = entrypoint[0]
87
raise RuntimeError('Too many database entry points defined')
88
# Instantiate the database entry point, ensure that it's of the right
89
# type, and initialize it. Then stash the object on our configuration
91
ep_object = entrypoint.load()
93
verifyObject(IDatabase, db)
95
Mailman.configuration.config.db = db
96
verifyObject(IListManager, db.list_manager)
97
Mailman.configuration.config.list_manager = db.list_manager
98
verifyObject(IUserManager, db.user_manager)
99
Mailman.configuration.config.user_manager = db.user_manager
71
102
def initialize(config=None, propagate_logs=False):