summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/config/schema.cfg2
-rw-r--r--src/mailman/database/alembic/env.py1
-rw-r--r--src/mailman/database/base.py15
-rw-r--r--src/mailman/database/factory.py8
-rw-r--r--src/mailman/database/model.py2
-rw-r--r--src/mailman/database/postgresql.py10
-rw-r--r--src/mailman/database/types.py3
-rw-r--r--src/mailman/model/message.py6
-rw-r--r--src/mailman/model/messagestore.py9
-rw-r--r--src/mailman/model/pending.py2
-rw-r--r--src/mailman/styles/base.py8
-rw-r--r--src/mailman/utilities/importer.py3
12 files changed, 40 insertions, 29 deletions
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 3ed7d72da..f66c0b5b5 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -534,7 +534,7 @@ register_bounces_every: 15m
# following values.
# The class implementing the IArchiver interface.
-class:
+class:
# Set this to 'yes' to enable the archiver.
enable: no
diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py
index ee6d8293f..55f0418f1 100644
--- a/src/mailman/database/alembic/env.py
+++ b/src/mailman/database/alembic/env.py
@@ -63,6 +63,7 @@ def run_migrations_online():
alembic_cfg = Config()
alembic_cfg.set_main_option(
'script_location', expand_path(config.database['alembic_scripts']))
+ alembic_cfg.set_section_option('logger_alembic' ,'level' , 'ERROR')
url = expand(config.database.url, config.paths)
engine = create_engine(url)
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py
index e360dcedf..e49d512c0 100644
--- a/src/mailman/database/base.py
+++ b/src/mailman/database/base.py
@@ -25,6 +25,8 @@ __all__ = [
import logging
+from alembic import command
+from alembic.config import Config
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from zope.interface import implementer
@@ -32,6 +34,7 @@ from zope.interface import implementer
from mailman.config import config
from mailman.interfaces.database import IDatabase
from mailman.utilities.string import expand
+from mailman.utilities.modules import expand_path
log = logging.getLogger('mailman.config')
@@ -89,6 +92,18 @@ class SABaseDatabase:
"""
pass
+ def stamp(self, debug=False):
+ """Stamp the database with the latest Alembic version."""
+ # Newly created databases don't need migrations from Alembic, since
+ # create_all() ceates the latest schema. This patches the database
+ # with the latest Alembic version to add an entry in the
+ # alembic_version table.
+ alembic_cfg = Config()
+ alembic_cfg.set_main_option(
+ 'script_location', expand_path(config.database['alembic_scripts']))
+ command.stamp(alembic_cfg, 'head')
+
+
def initialize(self, debug=None):
"""See `IDatabase`."""
# Calculate the engine url.
diff --git a/src/mailman/database/factory.py b/src/mailman/database/factory.py
index 189fd6ac4..0a295331a 100644
--- a/src/mailman/database/factory.py
+++ b/src/mailman/database/factory.py
@@ -29,11 +29,7 @@ __all__ = [
import os
import types
-from alembic import command
-from alembic.config import Config
-
from flufl.lock import Lock
-from pkg_resources import resource_filename
from zope.interface import implementer
from zope.interface.verify import verifyObject
@@ -57,9 +53,7 @@ class DatabaseFactory:
verifyObject(IDatabase, database)
database.initialize()
Model.metadata.create_all(database.engine)
- alembic_cfg = Config(
- resource_filename('mailman.config', 'alembic.ini'))
- command.stamp(alembic_cfg, 'head')
+ database.stamp()
database.commit()
return database
diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py
index 06705dfe9..b65d7d5eb 100644
--- a/src/mailman/database/model.py
+++ b/src/mailman/database/model.py
@@ -49,7 +49,7 @@ class ModelMeta:
for table in reversed(Model.metadata.sorted_tables):
connection.execute(table.delete())
except:
- transaction.abort()
+ transaction.rollback()
raise
else:
transaction.commit()
diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py
index 59fff0865..717b69dd1 100644
--- a/src/mailman/database/postgresql.py
+++ b/src/mailman/database/postgresql.py
@@ -26,7 +26,7 @@ __all__ = [
from mailman.database.base import SABaseDatabase
-from operator import attrgetter
+from mailman.database.model import Model
@@ -40,15 +40,13 @@ class PostgreSQLDatabase(SABaseDatabase):
restart from zero for new tests.
"""
super(PostgreSQLDatabase, self)._post_reset(store)
- from mailman.database.model import ModelMeta
- classes = sorted(ModelMeta._class_registry,
- key=attrgetter('__storm_table__'))
+ tables = reversed(Model.metadata.sorted_tables)
# Recipe adapted from
# http://stackoverflow.com/questions/544791/
# django-postgresql-how-to-reset-primary-key
- for model_class in classes:
+ for table in tables:
store.execute("""\
SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1),
max("id") IS NOT null)
FROM "{0}";
- """.format(model_class.__storm_table__))
+ """.format(table))
diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py
index 641e065ba..1984b08b5 100644
--- a/src/mailman/database/types.py
+++ b/src/mailman/database/types.py
@@ -29,6 +29,7 @@ __all__ = [
import uuid
from sqlalchemy import Integer
+from sqlalchemy.dialects import postgresql
from sqlalchemy.types import TypeDecorator, CHAR
@@ -68,7 +69,7 @@ class UUID(TypeDecorator):
def load_dialect_impl(self, dialect):
if dialect.name == 'postgresql':
- return dialect.type_descriptor(UUID())
+ return dialect.type_descriptor(postgresql.UUID())
else:
return dialect.type_descriptor(CHAR(32))
diff --git a/src/mailman/model/message.py b/src/mailman/model/message.py
index 74a76ac30..691861d46 100644
--- a/src/mailman/model/message.py
+++ b/src/mailman/model/message.py
@@ -40,10 +40,10 @@ class Message(Model):
__tablename__ = 'message'
id = Column(Integer, primary_key=True)
- message_id = Column(Unicode)
- message_id_hash = Column(Unicode)
- path = Column(LargeBinary) # TODO : was RawStr()
# This is a Messge-ID field representation, not a database row id.
+ message_id = Column(Unicode)
+ message_id_hash = Column(LargeBinary)
+ path = Column(LargeBinary)
@dbconnection
def __init__(self, store, message_id, message_id_hash, path):
diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py
index 225d3d1ce..19fa8133f 100644
--- a/src/mailman/model/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -66,7 +66,7 @@ class MessageStore:
'Message ID already exists in message store: {0}'.format(
message_id))
shaobj = hashlib.sha1(message_id)
- hash32 = base64.b32encode(shaobj.digest()).decode('ascii')
+ hash32 = base64.b32encode(shaobj.digest())
del message['X-Message-ID-Hash']
message['X-Message-ID-Hash'] = hash32
# Calculate the path on disk where we're going to store this message
@@ -115,8 +115,11 @@ class MessageStore:
@dbconnection
def get_message_by_hash(self, store, message_id_hash):
- if isinstance(message_id_hash, bytes):
- message_id_hash = message_id_hash.decode('utf-8')
+ # It's possible the hash came from a message header, in which case it
+ # will be a Unicode. However when coming from source code, it may be
+ # bytes object. Coerce to the latter if necessary; it must be ASCII.
+ if not isinstance(message_id_hash, bytes):
+ message_id_hash = message_id_hash.encode('ascii')
row = store.query(Message).filter_by(
message_id_hash=message_id_hash).first()
if row is None:
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py
index 68a8cd63e..691e94fd9 100644
--- a/src/mailman/model/pending.py
+++ b/src/mailman/model/pending.py
@@ -71,7 +71,7 @@ class Pended(Model):
__tablename__ = 'pended'
id = Column(Integer, primary_key=True)
- token = Column(LargeBinary) # TODO : was RawStr()
+ token = Column(LargeBinary)
expiration_date = Column(DateTime)
key_values = relationship('PendedKeyValue')
diff --git a/src/mailman/styles/base.py b/src/mailman/styles/base.py
index d83b2e2a5..0d65bbebb 100644
--- a/src/mailman/styles/base.py
+++ b/src/mailman/styles/base.py
@@ -64,12 +64,8 @@ class Identity:
mlist.info = ''
mlist.preferred_language = 'en'
mlist.subject_prefix = _('[$mlist.display_name] ')
- # Set this to Never if the list's preferred language uses us-ascii,
- # otherwise set it to As Needed.
- if mlist.preferred_language.charset == 'us-ascii':
- mlist.encode_ascii_prefixes = 0
- else:
- mlist.encode_ascii_prefixes = 2
+ mlist.encode_ascii_prefixes = (
+ mlist.preferred_language.charset != 'us-ascii')
diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py
index 26b7261e3..5b2be9742 100644
--- a/src/mailman/utilities/importer.py
+++ b/src/mailman/utilities/importer.py
@@ -172,6 +172,9 @@ TYPES = dict(
personalize=Personalization,
preferred_language=check_language_code,
reply_goes_to_list=ReplyToMunging,
+ allow_list_posts=bool,
+ include_rfc2369_headers=bool,
+ nntp_prefix_subject_too=bool,
)