Aurélien Bompard has proposed merging lp:~abompard/mailman/lp1435941 into 
lp:mailman.

Requested reviews:
  Mailman Coders (mailman-coders)
Related bugs:
  Bug #1435941 in GNU Mailman: "Postgresql support is broken"
  https://bugs.launchpad.net/mailman/+bug/1435941

For more details, see:
https://code.launchpad.net/~abompard/mailman/lp1435941/+merge/257090

Here's how I think we should fix bug #1435941.
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~abompard/mailman/lp1435941 into lp:mailman.
=== 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 @@
         var_dir = os.environ.get('MAILMAN_VAR_DIR')
         if var_dir is not None:
             env['MAILMAN_VAR_DIR'] = var_dir
-        # For the testing framework, if this environment variable is set, pass
-        # it on to the subprocess.
-        coverage_env = os.environ.get('COVERAGE_PROCESS_START')
-        if coverage_env is not None:
-            env['COVERAGE_PROCESS_START'] = coverage_env
+        # For the testing framework, if these environment variables are set,
+        # pass them on to the subprocess.
+        for envvar in ('COVERAGE_PROCESS_START', 'MAILMAN_EXTRA_TESTING_CFG'):
+            if envvar in os.environ:
+                env[envvar] = os.environ[envvar]
         args.append(env)
         os.execle(*args)
         # We should never get here.

=== 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 @@
         database = call_name(database_class)
         verifyObject(IDatabase, database)
         database.initialize()
+        # Remove existing tables (PostgreSQL will keep them across runs)
+        tmpmd = MetaData(bind=database.engine)
+        tmpmd.reflect()
+        tmpmd.drop_all()
+        database.commit()
+        # Now create the current model without Alembic upgrades
         Model.metadata.create_all(database.engine)
         database.commit()
         # Make _reset() a bound method of the database instance.

=== 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 @@
 
 from mailman.database.base import SABaseDatabase
 from mailman.database.model import Model
+from sqlalchemy import Integer
 
 
 
@@ -42,8 +43,11 @@
         # http://stackoverflow.com/questions/544791/
         # django-postgresql-how-to-reset-primary-key
         for table in tables:
-            store.execute("""\
-                SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1),
-                              max("id") IS NOT null)
-                       FROM "{0}";
-                """.format(table))
+            for column in table.primary_key:
+                if column.autoincrement and isinstance(column.type, Integer) \
+                    and not column.foreign_keys:
+                    store.execute("""\
+                        SELECT setval('"{0}_{1}_seq"', coalesce(max("{1}"), 1),
+                                      max("{1}") IS NOT null)
+                               FROM "{0}";
+                        """.format(table, column.name))

=== 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 @@
 from mailman.interfaces.usermanager import IUserManager
 from mailman.utilities.filesystem import makedirs
 from mailman.utilities.i18n import search
+from sqlalchemy import Boolean
 from urllib.error import URLError
 from zope.component import getUtility
 
@@ -153,7 +154,6 @@
 
 # Attributes in Mailman 2 which have a different type in Mailman 3.
 TYPES = dict(
-    allow_list_posts=bool,
     autorespond_owner=ResponseAction,
     autorespond_postings=ResponseAction,
     autorespond_requests=ResponseAction,
@@ -163,24 +163,18 @@
     default_member_action=member_action_mapping,
     default_nonmember_action=nonmember_action_mapping,
     digest_volume_frequency=DigestFrequency,
-    emergency=bool,
-    encode_ascii_prefixes=bool,
     filter_action=filter_action_mapping,
     filter_extensions=list_members_to_unicode,
     filter_types=list_members_to_unicode,
     forward_unrecognized_bounces_to=UnrecognizedBounceDisposition,
-    gateway_to_mail=bool,
-    include_rfc2369_headers=bool,
     moderator_password=str_to_bytes,
     newsgroup_moderation=NewsgroupModeration,
-    nntp_prefix_subject_too=bool,
     pass_extensions=list_members_to_unicode,
     pass_types=list_members_to_unicode,
     personalize=Personalization,
     preferred_language=check_language_code,
     reply_goes_to_list=ReplyToMunging,
     subscription_policy=SubscriptionPolicy,
-    topics_enabled=bool,
     )
 
 
@@ -253,6 +247,10 @@
                 value = bytes_to_str(value)
             # Some types require conversion.
             converter = TYPES.get(key)
+            if converter is None:
+                column = getattr(mlist.__class__, key, None)
+                if column is not None and isinstance(column.type, Boolean):
+                    converter = bool
             try:
                 if converter is not None:
                     value = converter(value)

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to