summaryrefslogtreecommitdiff
path: root/Mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2008-02-25 00:24:03 -0500
committerBarry Warsaw2008-02-25 00:24:03 -0500
commit6965bd89216a8d759ff8ea35ca4d1e88b0c35906 (patch)
tree642089474463c2632ab358a8f6d982af19ed24ca /Mailman/database
parentaab29f252ebefb1520714080a90bb42a25393f18 (diff)
downloadmailman-6965bd89216a8d759ff8ea35ca4d1e88b0c35906.tar.gz
mailman-6965bd89216a8d759ff8ea35ca4d1e88b0c35906.tar.zst
mailman-6965bd89216a8d759ff8ea35ca4d1e88b0c35906.zip
Rework the basic infrastructure for qrunner process control. Split out the
functionality of mailmanctl into a separate master watcher script. mailmanctl has not yet been updated but that'll happen next. Fix DELIVERY_MODULE to name a handler instead of a module. Change make_instance to use pkg_resources instead of module.__file__. Change the qrunner and master processes coordination so that the qrunners are not restarted on SIGINT, because otherwise C-c just doesn't work. Now SIGUSR1 is how we'll implement 'mailman restart'. Add a database commit so that initializing the schema doesn't lock the sqlite database. Also, don't try to initialize the schema if the tables already exist. Use some sqlite magic to do this test. Move mailman.cfg.in into a new package Mailman/extras inside the tree. Also, MAILMAN_UID and MAILMAN_GID should be integers not strings. Convert the command runner to use an IHandler instance instead of handler module. Similarly for the outgoing runner, DELIVERY_MODULE now names an IHandler instance instead of a handler module.
Diffstat (limited to 'Mailman/database')
-rw-r--r--Mailman/database/__init__.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/Mailman/database/__init__.py b/Mailman/database/__init__.py
index 7ca60f145..63bdd110c 100644
--- a/Mailman/database/__init__.py
+++ b/Mailman/database/__init__.py
@@ -23,7 +23,6 @@ __all__ = [
]
import os
-import Mailman.Version
from locknix.lockfile import Lock
from storm.locals import create_database, Store
@@ -31,6 +30,9 @@ from string import Template
from urlparse import urlparse
from zope.interface import implements
+import Mailman.Version
+import Mailman.database
+
from Mailman.configuration import config
from Mailman.database.listmanager import ListManager
from Mailman.database.messagestore import MessageStore
@@ -87,17 +89,23 @@ class StockDatabase:
store = Store(database)
database.DEBUG = (config.DEFAULT_DATABASE_ECHO
if debug is None else debug)
+ # Check the sqlite master database to see if the version file exists.
+ # If so, then we assume the database schema is correctly initialized.
# Storm does not currently have schema creation. This is not an ideal
# way to handle creating the database, but it's cheap and easy for
# now.
- import Mailman.database
- schema_file = os.path.join(
- os.path.dirname(Mailman.database.__file__),
- 'mailman.sql')
- with open(schema_file) as fp:
- sql = fp.read()
- for statement in sql.split(';'):
- store.execute(statement + ';')
+ table_names = [item[0] for item in
+ store.execute('select tbl_name from sqlite_master;')]
+ if 'version' not in table_names:
+ # Initialize the database.
+ schema_file = os.path.join(
+ os.path.dirname(Mailman.database.__file__),
+ 'mailman.sql')
+ with open(schema_file) as fp:
+ sql = fp.read()
+ for statement in sql.split(';'):
+ store.execute(statement + ';')
+ store.commit()
# Validate schema version.
v = store.find(Version, component=u'schema').one()
if not v: