Merge lp:~abompard/mailman/lp1435941 into lp:mailman

Proposed by Aurélien Bompard on 2015-04-22
Status: Merged
Approved by: Barry Warsaw on 2015-04-22
Approved revision: 7338
Merged at revision: 7336
Proposed branch: lp:~abompard/mailman/lp1435941
Merge into: lp:mailman
Diff against target: 122 lines (+25/-17)
4 files modified
src/mailman/bin/master.py (+5/-5)
src/mailman/database/factory.py (+6/-0)
src/mailman/database/postgresql.py (+9/-5)
src/mailman/utilities/importer.py (+5/-7)
To merge this branch: bzr merge lp:~abompard/mailman/lp1435941
Reviewer Review Type Date Requested Status
Barry Warsaw 2015-04-22 Approve on 2015-04-22
Review via email: mp+257090@code.launchpad.net

Description of the change

Here's how I think we should fix bug #1435941.

To post a comment you must log in.
Barry Warsaw (barry) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mailman/bin/master.py'
2--- src/mailman/bin/master.py 2015-03-12 16:20:52 +0000
3+++ src/mailman/bin/master.py 2015-04-22 13:37:22 +0000
4@@ -373,11 +373,11 @@
5 var_dir = os.environ.get('MAILMAN_VAR_DIR')
6 if var_dir is not None:
7 env['MAILMAN_VAR_DIR'] = var_dir
8- # For the testing framework, if this environment variable is set, pass
9- # it on to the subprocess.
10- coverage_env = os.environ.get('COVERAGE_PROCESS_START')
11- if coverage_env is not None:
12- env['COVERAGE_PROCESS_START'] = coverage_env
13+ # For the testing framework, if these environment variables are set,
14+ # pass them on to the subprocess.
15+ for envvar in ('COVERAGE_PROCESS_START', 'MAILMAN_EXTRA_TESTING_CFG'):
16+ if envvar in os.environ:
17+ env[envvar] = os.environ[envvar]
18 args.append(env)
19 os.execle(*args)
20 # We should never get here.
21
22=== modified file 'src/mailman/database/factory.py'
23--- src/mailman/database/factory.py 2015-01-05 01:22:39 +0000
24+++ src/mailman/database/factory.py 2015-04-22 13:37:22 +0000
25@@ -135,6 +135,12 @@
26 database = call_name(database_class)
27 verifyObject(IDatabase, database)
28 database.initialize()
29+ # Remove existing tables (PostgreSQL will keep them across runs)
30+ tmpmd = MetaData(bind=database.engine)
31+ tmpmd.reflect()
32+ tmpmd.drop_all()
33+ database.commit()
34+ # Now create the current model without Alembic upgrades
35 Model.metadata.create_all(database.engine)
36 database.commit()
37 # Make _reset() a bound method of the database instance.
38
39=== modified file 'src/mailman/database/postgresql.py'
40--- src/mailman/database/postgresql.py 2015-01-05 01:22:39 +0000
41+++ src/mailman/database/postgresql.py 2015-04-22 13:37:22 +0000
42@@ -24,6 +24,7 @@
43
44 from mailman.database.base import SABaseDatabase
45 from mailman.database.model import Model
46+from sqlalchemy import Integer
47
48
49
50
51@@ -42,8 +43,11 @@
52 # http://stackoverflow.com/questions/544791/
53 # django-postgresql-how-to-reset-primary-key
54 for table in tables:
55- store.execute("""\
56- SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1),
57- max("id") IS NOT null)
58- FROM "{0}";
59- """.format(table))
60+ for column in table.primary_key:
61+ if column.autoincrement and isinstance(column.type, Integer) \
62+ and not column.foreign_keys:
63+ store.execute("""\
64+ SELECT setval('"{0}_{1}_seq"', coalesce(max("{1}"), 1),
65+ max("{1}") IS NOT null)
66+ FROM "{0}";
67+ """.format(table, column.name))
68
69=== modified file 'src/mailman/utilities/importer.py'
70--- src/mailman/utilities/importer.py 2015-03-26 07:22:45 +0000
71+++ src/mailman/utilities/importer.py 2015-04-22 13:37:22 +0000
72@@ -47,6 +47,7 @@
73 from mailman.interfaces.usermanager import IUserManager
74 from mailman.utilities.filesystem import makedirs
75 from mailman.utilities.i18n import search
76+from sqlalchemy import Boolean
77 from urllib.error import URLError
78 from zope.component import getUtility
79
80@@ -153,7 +154,6 @@
81
82
83 # Attributes in Mailman 2 which have a different type in Mailman 3.
84 TYPES = dict(
85- allow_list_posts=bool,
86 autorespond_owner=ResponseAction,
87 autorespond_postings=ResponseAction,
88 autorespond_requests=ResponseAction,
89@@ -163,24 +163,18 @@
90 default_member_action=member_action_mapping,
91 default_nonmember_action=nonmember_action_mapping,
92 digest_volume_frequency=DigestFrequency,
93- emergency=bool,
94- encode_ascii_prefixes=bool,
95 filter_action=filter_action_mapping,
96 filter_extensions=list_members_to_unicode,
97 filter_types=list_members_to_unicode,
98 forward_unrecognized_bounces_to=UnrecognizedBounceDisposition,
99- gateway_to_mail=bool,
100- include_rfc2369_headers=bool,
101 moderator_password=str_to_bytes,
102 newsgroup_moderation=NewsgroupModeration,
103- nntp_prefix_subject_too=bool,
104 pass_extensions=list_members_to_unicode,
105 pass_types=list_members_to_unicode,
106 personalize=Personalization,
107 preferred_language=check_language_code,
108 reply_goes_to_list=ReplyToMunging,
109 subscription_policy=SubscriptionPolicy,
110- topics_enabled=bool,
111 )
112
113
114@@ -253,6 +247,10 @@
115 value = bytes_to_str(value)
116 # Some types require conversion.
117 converter = TYPES.get(key)
118+ if converter is None:
119+ column = getattr(mlist.__class__, key, None)
120+ if column is not None and isinstance(column.type, Boolean):
121+ converter = bool
122 try:
123 if converter is not None:
124 value = converter(value)