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

Proposed by Aurélien Bompard
Status: Merged
Approved by: Barry Warsaw
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 Approve
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.
Revision history for this message
Barry Warsaw (barry) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/mailman/bin/master.py'
--- src/mailman/bin/master.py 2015-03-12 16:20:52 +0000
+++ src/mailman/bin/master.py 2015-04-22 13:37:22 +0000
@@ -373,11 +373,11 @@
373 var_dir = os.environ.get('MAILMAN_VAR_DIR')373 var_dir = os.environ.get('MAILMAN_VAR_DIR')
374 if var_dir is not None:374 if var_dir is not None:
375 env['MAILMAN_VAR_DIR'] = var_dir375 env['MAILMAN_VAR_DIR'] = var_dir
376 # For the testing framework, if this environment variable is set, pass376 # For the testing framework, if these environment variables are set,
377 # it on to the subprocess.377 # pass them on to the subprocess.
378 coverage_env = os.environ.get('COVERAGE_PROCESS_START')378 for envvar in ('COVERAGE_PROCESS_START', 'MAILMAN_EXTRA_TESTING_CFG'):
379 if coverage_env is not None:379 if envvar in os.environ:
380 env['COVERAGE_PROCESS_START'] = coverage_env380 env[envvar] = os.environ[envvar]
381 args.append(env)381 args.append(env)
382 os.execle(*args)382 os.execle(*args)
383 # We should never get here.383 # We should never get here.
384384
=== modified file 'src/mailman/database/factory.py'
--- src/mailman/database/factory.py 2015-01-05 01:22:39 +0000
+++ src/mailman/database/factory.py 2015-04-22 13:37:22 +0000
@@ -135,6 +135,12 @@
135 database = call_name(database_class)135 database = call_name(database_class)
136 verifyObject(IDatabase, database)136 verifyObject(IDatabase, database)
137 database.initialize()137 database.initialize()
138 # Remove existing tables (PostgreSQL will keep them across runs)
139 tmpmd = MetaData(bind=database.engine)
140 tmpmd.reflect()
141 tmpmd.drop_all()
142 database.commit()
143 # Now create the current model without Alembic upgrades
138 Model.metadata.create_all(database.engine)144 Model.metadata.create_all(database.engine)
139 database.commit()145 database.commit()
140 # Make _reset() a bound method of the database instance.146 # Make _reset() a bound method of the database instance.
141147
=== modified file 'src/mailman/database/postgresql.py'
--- src/mailman/database/postgresql.py 2015-01-05 01:22:39 +0000
+++ src/mailman/database/postgresql.py 2015-04-22 13:37:22 +0000
@@ -24,6 +24,7 @@
2424
25from mailman.database.base import SABaseDatabase25from mailman.database.base import SABaseDatabase
26from mailman.database.model import Model26from mailman.database.model import Model
27from sqlalchemy import Integer
2728
2829
2930
3031
@@ -42,8 +43,11 @@
42 # http://stackoverflow.com/questions/544791/43 # http://stackoverflow.com/questions/544791/
43 # django-postgresql-how-to-reset-primary-key44 # django-postgresql-how-to-reset-primary-key
44 for table in tables:45 for table in tables:
45 store.execute("""\46 for column in table.primary_key:
46 SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1),47 if column.autoincrement and isinstance(column.type, Integer) \
47 max("id") IS NOT null)48 and not column.foreign_keys:
48 FROM "{0}";49 store.execute("""\
49 """.format(table))50 SELECT setval('"{0}_{1}_seq"', coalesce(max("{1}"), 1),
51 max("{1}") IS NOT null)
52 FROM "{0}";
53 """.format(table, column.name))
5054
=== modified file 'src/mailman/utilities/importer.py'
--- src/mailman/utilities/importer.py 2015-03-26 07:22:45 +0000
+++ src/mailman/utilities/importer.py 2015-04-22 13:37:22 +0000
@@ -47,6 +47,7 @@
47from mailman.interfaces.usermanager import IUserManager47from mailman.interfaces.usermanager import IUserManager
48from mailman.utilities.filesystem import makedirs48from mailman.utilities.filesystem import makedirs
49from mailman.utilities.i18n import search49from mailman.utilities.i18n import search
50from sqlalchemy import Boolean
50from urllib.error import URLError51from urllib.error import URLError
51from zope.component import getUtility52from zope.component import getUtility
5253
@@ -153,7 +154,6 @@
153154
154155
155# Attributes in Mailman 2 which have a different type in Mailman 3.156# Attributes in Mailman 2 which have a different type in Mailman 3.
156TYPES = dict(157TYPES = dict(
157 allow_list_posts=bool,
158 autorespond_owner=ResponseAction,158 autorespond_owner=ResponseAction,
159 autorespond_postings=ResponseAction,159 autorespond_postings=ResponseAction,
160 autorespond_requests=ResponseAction,160 autorespond_requests=ResponseAction,
@@ -163,24 +163,18 @@
163 default_member_action=member_action_mapping,163 default_member_action=member_action_mapping,
164 default_nonmember_action=nonmember_action_mapping,164 default_nonmember_action=nonmember_action_mapping,
165 digest_volume_frequency=DigestFrequency,165 digest_volume_frequency=DigestFrequency,
166 emergency=bool,
167 encode_ascii_prefixes=bool,
168 filter_action=filter_action_mapping,166 filter_action=filter_action_mapping,
169 filter_extensions=list_members_to_unicode,167 filter_extensions=list_members_to_unicode,
170 filter_types=list_members_to_unicode,168 filter_types=list_members_to_unicode,
171 forward_unrecognized_bounces_to=UnrecognizedBounceDisposition,169 forward_unrecognized_bounces_to=UnrecognizedBounceDisposition,
172 gateway_to_mail=bool,
173 include_rfc2369_headers=bool,
174 moderator_password=str_to_bytes,170 moderator_password=str_to_bytes,
175 newsgroup_moderation=NewsgroupModeration,171 newsgroup_moderation=NewsgroupModeration,
176 nntp_prefix_subject_too=bool,
177 pass_extensions=list_members_to_unicode,172 pass_extensions=list_members_to_unicode,
178 pass_types=list_members_to_unicode,173 pass_types=list_members_to_unicode,
179 personalize=Personalization,174 personalize=Personalization,
180 preferred_language=check_language_code,175 preferred_language=check_language_code,
181 reply_goes_to_list=ReplyToMunging,176 reply_goes_to_list=ReplyToMunging,
182 subscription_policy=SubscriptionPolicy,177 subscription_policy=SubscriptionPolicy,
183 topics_enabled=bool,
184 )178 )
185179
186180
@@ -253,6 +247,10 @@
253 value = bytes_to_str(value)247 value = bytes_to_str(value)
254 # Some types require conversion.248 # Some types require conversion.
255 converter = TYPES.get(key)249 converter = TYPES.get(key)
250 if converter is None:
251 column = getattr(mlist.__class__, key, None)
252 if column is not None and isinstance(column.type, Boolean):
253 converter = bool
256 try:254 try:
257 if converter is not None:255 if converter is not None:
258 value = converter(value)256 value = converter(value)