summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2007-01-02 02:42:34 +0000
committerbwarsaw2007-01-02 02:42:34 +0000
commitd7da90ebc8aeee180ba470c002f7e37ef7df1089 (patch)
tree8e5cb355d59b880a171078d9425ebf4c6cd325d5
parent7971cdb1d36862db483547c974f1e2e40980f3d3 (diff)
downloadmailman-d7da90ebc8aeee180ba470c002f7e37ef7df1089.tar.gz
mailman-d7da90ebc8aeee180ba470c002f7e37ef7df1089.tar.zst
mailman-d7da90ebc8aeee180ba470c002f7e37ef7df1089.zip
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().
-rw-r--r--Mailman/Queue/HTTPRunner.py6
-rw-r--r--Mailman/bin/export.py11
-rw-r--r--Mailman/bin/import.py31
3 files changed, 31 insertions, 17 deletions
diff --git a/Mailman/Queue/HTTPRunner.py b/Mailman/Queue/HTTPRunner.py
index e2c053629..32620f458 100644
--- a/Mailman/Queue/HTTPRunner.py
+++ b/Mailman/Queue/HTTPRunner.py
@@ -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 @@ server = make_server(config.HTTP_HOST, config.HTTP_PORT,
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
diff --git a/Mailman/bin/export.py b/Mailman/bin/export.py
index 2bcdbf667..d83959279 100644
--- a/Mailman/bin/export.py
+++ b/Mailman/bin/export.py
@@ -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 os
import sys
import sha
import base64
+import codecs
import datetime
import optparse
@@ -143,7 +144,7 @@ class XMLDumper(object):
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 @@ class XMLDumper(object):
}.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 @@ def main():
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)
diff --git a/Mailman/bin/import.py b/Mailman/bin/import.py
index 3d1210c8f..68876def1 100644
--- a/Mailman/bin/import.py
+++ b/Mailman/bin/import.py
@@ -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.dom import minidom
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 @@ def parse_roster(node):
'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 @@ def load(fp):
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 @@ def create(all_listdata):
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 @@ def create(all_listdata):
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 @@ def main():
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)