Revision: 8130
          http://svn.sourceforge.net/mailman/?rev=8130&view=rev
Author:   bwarsaw
Date:     2007-01-01 18:42:34 -0800 (Mon, 01 Jan 2007)

Log Message:
-----------
Ported from 2.1 branch:

    Ensure that exported XML is written in utf-8, at least if we're writing to
    a file other than stdout.  Fix a typo in getting the digest style.  Update
    copyright years.

In HTTPRunner.py, catch KeyboardInterrupt.  In Python 2.5 this has been moved
in the exception hierarchy so that it's no longer caught by "except
Exception".

import.py: Import user topic selections.  Fix a typo in an error message.
Catch BadDomainSpecificationErrors that can be raised in MailList.Create().

Modified Paths:
--------------
    trunk/mailman/Mailman/Queue/HTTPRunner.py
    trunk/mailman/Mailman/bin/export.py
    trunk/mailman/Mailman/bin/import.py

Modified: trunk/mailman/Mailman/Queue/HTTPRunner.py
===================================================================
--- trunk/mailman/Mailman/Queue/HTTPRunner.py   2007-01-02 02:35:38 UTC (rev 
8129)
+++ trunk/mailman/Mailman/Queue/HTTPRunner.py   2007-01-02 02:42:34 UTC (rev 
8130)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 by the Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -63,6 +63,8 @@
 qlog.info('HTTPRunner qrunner started.')
 try:
     server.serve_forever()
-except:
+# Do it this way because of exception hierarchy changes in Python 2.5.  XXX
+# Change this to BaseException for Python 2.5.
+except (Exception, KeyboardInterrupt):
     qlog.exception('HTTPRunner qrunner exiting.')
     raise

Modified: trunk/mailman/Mailman/bin/export.py
===================================================================
--- trunk/mailman/Mailman/bin/export.py 2007-01-02 02:35:38 UTC (rev 8129)
+++ trunk/mailman/Mailman/bin/export.py 2007-01-02 02:42:34 UTC (rev 8130)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 by the Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
 import sys
 import sha
 import base64
+import codecs
 import datetime
 import optparse
 
@@ -143,7 +144,7 @@
             print >> self._fp, '<%s%s/>' % (_name, attrs)
         else:
             # The value might contain angle brackets.
-            value = escape(str(_value))
+            value = escape(unicode(_value))
             print >> self._fp, '<%s%s>%s</%s>' % (_name, attrs, value, _name)
 
     def _do_list_categories(self, mlist, k, subcat=None):
@@ -222,7 +223,7 @@
                                    }.get(mlist.getDeliveryStatus(member),
                                          'unknown')
             if member in digesters:
-                if mlist.getMemberOption('plain'):
+                if mlist.getMemberOption(member, Defaults.DisableMime):
                     attrs['delivery'] = 'plain'
                 else:
                     attrs['delivery'] = 'mime'
@@ -353,9 +354,11 @@
     config.load(opts.config)
 
     if opts.outputfile in (None, '-'):
+        # This will fail if there are characters in the output incompatible
+        # with system encoding.
         fp = sys.stdout
     else:
-        fp = open(opts.outputfile, 'w')
+        fp = codecs.open(opts.outputfile, 'w', 'utf-8')
 
     try:
         dumper = XMLDumper(fp)

Modified: trunk/mailman/Mailman/bin/import.py
===================================================================
--- trunk/mailman/Mailman/bin/import.py 2007-01-02 02:35:38 UTC (rev 8129)
+++ trunk/mailman/Mailman/bin/import.py 2007-01-02 02:42:34 UTC (rev 8130)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 by the Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -18,6 +18,7 @@
 """Import the XML representation of a mailing list."""
 
 import sys
+import codecs
 import optparse
 import traceback
 
@@ -25,6 +26,7 @@
 from xml.parsers.expat import ExpatError
 
 from Mailman import Defaults
+from Mailman import Errors
 from Mailman import MemberAdaptor
 from Mailman import Utils
 from Mailman import Version
@@ -135,8 +137,9 @@
                          'false': False,
                          }.get(nodetext(subnode).lower(), False)
             elif attr == 'topics':
-                # XXX
                 value = []
+                for subsubnode in nodegen(subnode):
+                    value.append(nodetext(subsubnode))
             else:
                 value = nodetext(subnode)
             member[attr] = value
@@ -149,7 +152,7 @@
     try:
         doc = minidom.parse(fp)
     except ExpatError:
-        print _('Expat error in file: %s', fp.name)
+        print _('Expat error in file: $fp.name')
         traceback.print_exc()
         sys.exit(1)
     doc.normalize()
@@ -190,10 +193,14 @@
             print _('Skipping already existing list: $fqdn_listname')
             continue
         mlist = MailList()
-        mlist.Create(fqdn_listname, list_config['owner'][0],
-                     list_config['password'])
-        if VERBOSE:
-            print _('Creating mailing list: $fqdn_listname')
+        try:
+            if VERBOSE:
+                print _('Creating mailing list: $fqdn_listname')
+            mlist.Create(fqdn_listname, list_config['owner'][0],
+                         list_config['password'])
+        except Errors.BadDomainSpecificationError:
+            print _('List is not in a supported domain: $fqdn_listname')
+            continue
         # Save the list creation, then unlock and relock the list.  This is so
         # that we use normal SQLAlchemy transactions to manage all the
         # attribute and membership updates.  Without this, no transaction will
@@ -226,7 +233,9 @@
                     mlist.setMemberOption(mid,
                                           Defaults.OPTINFO[opt],
                                           member[opt])
-                # XXX topics
+                topics = member.get('topics')
+                if topics:
+                    mlist.setMemberTopics(mid, topics)
             mlist.Save()
         finally:
             mlist.Unlock()
@@ -271,12 +280,12 @@
     parser, opts, args = parseargs()
     initialize(opts.config)
     VERBOSE = opts.verbose
-    
+
     if opts.inputfile in (None, '-'):
         fp = sys.stdin
     else:
-        fp = open(opts.inputfile)
-        
+        fp = open(opts.inputfile, 'r')
+
     try:
         listbags = load(fp)
         create(listbags)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to