diff options
| author | bwarsaw | 2006-07-30 19:21:02 +0000 |
|---|---|---|
| committer | bwarsaw | 2006-07-30 19:21:02 +0000 |
| commit | 347bd559f5559775ac489e89c47c1206eae0711c (patch) | |
| tree | 18cf9cf1ca5ca1feb786d3a6b0bd35b3078b5812 | |
| parent | 13185804a6a138449be016fe187833c6630af991 (diff) | |
| download | mailman-347bd559f5559775ac489e89c47c1206eae0711c.tar.gz mailman-347bd559f5559775ac489e89c47c1206eae0711c.tar.zst mailman-347bd559f5559775ac489e89c47c1206eae0711c.zip | |
Upgrade to email package version 4.0.1. Because email 4.0.1 is only
compatible back to Python 2.3, this change should not get back ported to
Mailman 2.1.
Port to Python 2.5. The non-test suite changes should get back ported to
Mailman 2.1 (which I will do next), but don't worry about the test suite ones
because MM2.1's test suite is hopeless. Specifically:
- In SecurityManager.py, fix the parsecookie() code to work with Python 2.5
generated cookie text. The latter was changed to be more RFC compliant so
it does not output training semicolons for each line of cookie text. This
broke the splitting rules, so now first split on newlines, then on ';\s*'.
This should work across all Python versions.
- In Python 2.5, exceptions are new-style, and thus are no longer of
ClassType. The instantiation type test in hold_for_approval() was too
naive.
- Raising strings generates deprecation warnings in Python 2.5. Switch the
one weird use of this in Utils.py to use a class exception. Don't call it
"quick exit" though because it's probably not.
- In the tests, use True/False instead of 1/0
- Use failUnless/failIf instead of assertEqual against True/False.
- In the tests, use Message.get_content_type() instead of Message.get_type()
since the latter is gone in email 4.0.1. Same with get_content_maintype()
and get_main_type().
| -rw-r--r-- | Mailman/Handlers/Hold.py | 2 | ||||
| -rw-r--r-- | Mailman/SecurityManager.py | 15 | ||||
| -rw-r--r-- | Mailman/Utils.py | 8 | ||||
| -rw-r--r-- | Mailman/testing/test_handlers.py | 22 | ||||
| -rw-r--r-- | Mailman/testing/test_message.py | 4 | ||||
| -rw-r--r-- | Mailman/testing/test_security_mgr.py | 28 | ||||
| -rw-r--r-- | misc/Makefile.in | 3 | ||||
| -rw-r--r-- | misc/email-2.5.7.tar.gz | bin | 1138518 -> 0 bytes | |||
| -rw-r--r-- | misc/email-4.0.1.tar.gz | bin | 0 -> 1205824 bytes |
9 files changed, 42 insertions, 40 deletions
diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py index 13a6c0130..337420a50 100644 --- a/Mailman/Handlers/Hold.py +++ b/Mailman/Handlers/Hold.py @@ -199,7 +199,7 @@ def hold_for_approval(mlist, msg, msgdata, exc): # BAW: This should really be tied into the email confirmation system so # that the message can be approved or denied via email as well as the # web. - if type(exc) is ClassType: + if isinstance(exc, ClassType) or isinstance(exc, type): # Go ahead and instantiate it now. exc = exc() listname = mlist.real_name diff --git a/Mailman/SecurityManager.py b/Mailman/SecurityManager.py index 46f90ad98..e97084cf1 100644 --- a/Mailman/SecurityManager.py +++ b/Mailman/SecurityManager.py @@ -343,11 +343,12 @@ splitter = re.compile(';\s*') def parsecookie(s): c = {} - for p in splitter.split(s): - try: - k, v = p.split('=', 1) - except ValueError: - pass - else: - c[k] = v + for line in s.splitlines(): + for p in splitter.split(line): + try: + k, v = p.split('=', 1) + except ValueError: + pass + else: + c[k] = v return c diff --git a/Mailman/Utils.py b/Mailman/Utils.py index b190e2ded..53ece3ecd 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -432,6 +432,9 @@ def UnobscureEmail(addr): +class OuterExit(Exception): + pass + def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): # Make some text from a template file. The order of searches depends on # whether mlist and lang are provided. Once the templatefile is found, @@ -498,7 +501,6 @@ def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): searchdirs.append(os.path.join(config.TEMPLATE_DIR, 'site')) searchdirs.append(config.TEMPLATE_DIR) # Start scanning - quickexit = 'quickexit' fp = None try: for lang in languages: @@ -506,12 +508,12 @@ def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): filename = os.path.join(dir, lang, templatefile) try: fp = open(filename) - raise quickexit + raise OuterExit except IOError, e: if e.errno <> errno.ENOENT: raise # Okay, it doesn't exist, keep looping fp = None - except quickexit: + except OuterExit: pass if fp is None: # Try one last time with the distro English template, which, unless diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py index 1c38daa8b..e36af3b0f 100644 --- a/Mailman/testing/test_handlers.py +++ b/Mailman/testing/test_handlers.py @@ -131,7 +131,7 @@ From: aperson@example.org eq(str(str(qmsg['subject'])), '_xtest post acknowledgement') eq(qmsg['to'], 'aperson@example.org') eq(qmsg['from'], '_xtest-bounces@example.com') - eq(qmsg.get_type(), 'text/plain') + eq(qmsg.get_content_type(), 'text/plain') eq(qmsg.get_param('charset'), 'us-ascii') msgid = qmsg['message-id'] self.failUnless(msgid.startswith('<mailman.')) @@ -171,7 +171,7 @@ Subject: Wish you were here eq(str(qmsg['subject']), '_xtest post acknowledgement') eq(qmsg['to'], 'aperson@example.org') eq(qmsg['from'], '_xtest-bounces@example.com') - eq(qmsg.get_type(), 'text/plain') + eq(qmsg.get_content_type(), 'text/plain') eq(qmsg.get_param('charset'), 'us-ascii') msgid = qmsg['message-id'] self.failUnless(msgid.startswith('<mailman.')) @@ -1166,7 +1166,7 @@ yyy MimeDel.process(self._mlist, msg, {}) eq(len(msg.get_payload()), 1) subpart = msg.get_payload(0) - eq(subpart.get_type(), 'image/gif') + eq(subpart.get_content_type(), 'image/gif') eq(subpart.get_payload(), 'yyy') def test_collapse_multipart_alternative(self): @@ -1197,9 +1197,9 @@ yyy """) MimeDel.process(self._mlist, msg, {}) eq(len(msg.get_payload()), 1) - eq(msg.get_type(), 'multipart/mixed') + eq(msg.get_content_type(), 'multipart/mixed') subpart = msg.get_payload(0) - eq(subpart.get_type(), 'image/gif') + eq(subpart.get_content_type(), 'image/gif') eq(subpart.get_payload(), 'yyy') def test_convert_to_plaintext(self): @@ -1217,7 +1217,7 @@ MIME-Version: 1.0 <body></body></html> """) MimeDel.process(self._mlist, msg, {}) - eq(msg.get_type(), 'text/plain') + eq(msg.get_content_type(), 'text/plain') eq(msg.get_payload(), '\n\n\n') def test_deep_structure(self): @@ -1266,13 +1266,13 @@ aaa payload = msg.get_payload() eq(len(payload), 3) part1 = msg.get_payload(0) - eq(part1.get_type(), 'text/plain') + eq(part1.get_content_type(), 'text/plain') eq(part1.get_payload(), 'A different message') part2 = msg.get_payload(1) - eq(part2.get_type(), 'image/gif') + eq(part2.get_content_type(), 'image/gif') eq(part2.get_payload(), 'zzz') part3 = msg.get_payload(2) - eq(part3.get_type(), 'image/gif') + eq(part3.get_content_type(), 'image/gif') eq(part3.get_payload(), 'aaa') def test_top_multipart_alternative(self): @@ -1293,7 +1293,7 @@ This is plain text --AAA-- """) MimeDel.process(self._mlist, msg, {}) - eq(msg.get_type(), 'text/plain') + eq(msg.get_content_type(), 'text/plain') eq(msg.get_payload(), 'This is plain text') @@ -1568,7 +1568,7 @@ Here is message %(i)d # is the RFC 1153 digest. for filebase in files: qmsg, qdata = self._sb.dequeue(filebase) - if qmsg.get_main_type() == 'multipart': + if qmsg.get_content_maintype() == 'multipart': mimemsg = qmsg mimedata = qdata else: diff --git a/Mailman/testing/test_message.py b/Mailman/testing/test_message.py index 822449064..34e5c0139 100644 --- a/Mailman/testing/test_message.py +++ b/Mailman/testing/test_message.py @@ -82,10 +82,10 @@ yadda yadda yadda # second message is the message/rfc822 attachment of the original # message. msg1 = qmsg.get_payload(0) - eq(msg1.get_type(), 'text/plain') + eq(msg1.get_content_type(), 'text/plain') eq(msg1.get_payload(), '[No bounce details are available]') msg2 = qmsg.get_payload(1) - eq(msg2.get_type(), 'message/rfc822') + eq(msg2.get_content_type(), 'message/rfc822') unless(msg2.is_multipart()) msg3 = msg2.get_payload(0) eq(msg3.get_payload(), 'yadda yadda yadda\n') diff --git a/Mailman/testing/test_security_mgr.py b/Mailman/testing/test_security_mgr.py index ea7db5d9f..4b2515140 100644 --- a/Mailman/testing/test_security_mgr.py +++ b/Mailman/testing/test_security_mgr.py @@ -90,8 +90,8 @@ class TestSecurityManager(TestBase): class TestAuthenticate(TestBase): def setUp(self): TestBase.setUp(self) - Utils.set_global_password('bbBBbb', siteadmin=1) - Utils.set_global_password('ccCCcc', siteadmin=0) + Utils.set_global_password('bbBBbb', siteadmin=True) + Utils.set_global_password('ccCCcc', siteadmin=False) def tearDown(self): try: @@ -206,8 +206,8 @@ class StripperIO(StringIO): class TestWebAuthenticate(TestBase): def setUp(self): TestBase.setUp(self) - Utils.set_global_password('bbBBbb', siteadmin=1) - Utils.set_global_password('ccCCcc', siteadmin=0) + Utils.set_global_password('bbBBbb', siteadmin=True) + Utils.set_global_password('ccCCcc', siteadmin=False) mlist = self._mlist mlist.mod_password = password('abcdefg') mlist.addNewMember('aperson@dom.ain', password='qqQQqq') @@ -235,25 +235,25 @@ class TestWebAuthenticate(TestBase): TestBase.tearDown(self) def test_auth_site_admin(self): - self.assertEqual(self._mlist.WebAuthenticate( - [config.AuthSiteAdmin], 'xxxxxx'), 1) + self.failUnless(self._mlist.WebAuthenticate( + [config.AuthSiteAdmin], 'does not matter')) def test_list_admin(self): - self.assertEqual(self._mlist.WebAuthenticate( - [config.AuthListAdmin], 'xxxxxx'), 1) + self.failUnless(self._mlist.WebAuthenticate( + [config.AuthListAdmin], 'does not matter')) def test_list_moderator(self): - self.assertEqual(self._mlist.WebAuthenticate( - [config.AuthListModerator], 'xxxxxx'), 1) + self.failUnless(self._mlist.WebAuthenticate( + [config.AuthListModerator], 'does not matter')) def test_user(self): - self.assertEqual(self._mlist.WebAuthenticate( - [config.AuthUser], 'xxxxxx'), 1) + self.failUnless(self._mlist.WebAuthenticate( + [config.AuthUser], 'does not matter')) def test_not_a_user(self): self._mlist.removeMember('aperson@dom.ain') - self.assertEqual(self._mlist.WebAuthenticate( - [config.AuthUser], 'xxxxxx', 'aperson@dom.ain'), 0) + self.failIf(self._mlist.WebAuthenticate( + [config.AuthUser], 'does not matter', 'aperson@dom.ain')) diff --git a/misc/Makefile.in b/misc/Makefile.in index 6c1a3a55e..9227f63a9 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -53,7 +53,7 @@ SETUPINSTOPTS= --install-lib $(DESTDIR)$(PYTHONLIBDIR) \ --install-data $(DESTDIR)$(PYTHONLIBDIR) SETUPCMD= setup.py --quiet install $(SETUPINSTOPTS) -EMAILPKG= email-2.5.7 +EMAILPKG= email-4.0.1 PACKAGES= $(EMAILPKG) @@ -83,7 +83,6 @@ install-other: $(INSTALL) -m $(FILEMODE) paths.py $$dir; \ done $(INSTALL) -m $(EXEMODE) mailman $(DESTDIR)$(SCRIPTSDIR) - $(INSTALL) -m $(FILEMODE) sitelist.cfg $(DESTDIR)$(DATADIR) $(INSTALL) -m $(FILEMODE) mailman.cfg.sample $(DESTDIR)$(ETCDIR) install-packages: diff --git a/misc/email-2.5.7.tar.gz b/misc/email-2.5.7.tar.gz Binary files differdeleted file mode 100644 index 3f6a4bba8..000000000 --- a/misc/email-2.5.7.tar.gz +++ /dev/null diff --git a/misc/email-4.0.1.tar.gz b/misc/email-4.0.1.tar.gz Binary files differnew file mode 100644 index 000000000..589311b4e --- /dev/null +++ b/misc/email-4.0.1.tar.gz |
