[Mailman-checkins] [Git][mailman/mailman][master] 2 commits: Fixed an AttributeError in mailman/handlers/decorate.py when

2018-03-01 Thread Mark Sapiro via Mailman-checkins
Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
bbba16eb by Mark Sapiro at 2018-03-02T01:02:06Z
Fixed an AttributeError in mailman/handlers/decorate.py when
member.subscriber is an ``IUser`` instance rather than an ``IAddress``
instance.

- - - - -
7aba1621 by Mark Sapiro at 2018-03-02T02:22:40Z
Merge branch decorate into master

Fixed an AttributeError in mailman/handlers/decorate.py

Closes #449

See merge request mailman/mailman!357
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/handlers/decorate.py
- src/mailman/handlers/tests/test_decorate.py


Changes:

=
src/mailman/docs/NEWS.rst
=
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -55,6 +55,9 @@ Bugs
 * Messages with ``Subject`` headers encoded in an unknown character set no
   longer throw ``LookupError`` in subject prefixing.  (Closes #445)
 * A list's ``last_post_at`` is now properly updated.  (Closes #453)
+* Fixed an AttributeError in mailman/handlers/decorate.py when
+  member.subscriber is an ``IUser`` instance rather than an ``IAddress``
+  instance.  (Closes #449)
 
 Command line
 


=
src/mailman/handlers/decorate.py
=
--- a/src/mailman/handlers/decorate.py
+++ b/src/mailman/handlers/decorate.py
@@ -46,11 +46,18 @@ def process(mlist, msg, msgdata):
 member = msgdata.get('member')
 if member is not None:
 # Calculate the extra personalization dictionary.
-recipient = msgdata.get('recipient', member.address.original_email)
+# member.subscriber can be a User instance or an Address instance, and
+# member.address can be None and so can member._user.preferred_address.
+if member._address is not None:
+_address = member._address
+else:
+_address = (member._user.preferred_address or
+list(member._user.addresses)[0])
+recipient = msgdata.get('recipient', _address.original_email)
 d['member'] = formataddr(
-(member.subscriber.display_name, member.subscriber.email))
+(_address.display_name, _address.email))
 d['user_email'] = recipient
-d['user_delivered_to'] = member.address.original_email
+d['user_delivered_to'] = _address.original_email
 d['user_language'] = member.preferred_language.description
 d['user_name'] = member.display_name
 # For backward compatibility.


=
src/mailman/handlers/tests/test_decorate.py
=
--- a/src/mailman/handlers/tests/test_decorate.py
+++ b/src/mailman/handlers/tests/test_decorate.py
@@ -24,7 +24,11 @@ from mailman.app.lifecycle import create_list
 from mailman.config import config
 from mailman.handlers import decorate
 from mailman.interfaces.archiver import IArchiver
+from mailman.interfaces.member import MemberRole
 from mailman.interfaces.template import ITemplateManager
+from mailman.interfaces.usermanager import IUserManager
+from mailman.model.member import Member
+from mailman.model.preferences import Preferences
 from mailman.testing.helpers import (
 LogFileMark, specialized_message_from_string as mfs)
 from mailman.testing.layers import ConfigLayer
@@ -95,6 +99,44 @@ This is a test message.
 self.assertIn('http://example.com/link_to_message',
   self._msg.as_string())
 
+def test_decorate_member_as_address(self):
+site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
+os.makedirs(site_dir)
+footer_path = os.path.join(site_dir, 'myfooter.txt')
+with open(footer_path, 'w', encoding='utf-8') as fp:
+print('$member', file=fp)
+getUtility(ITemplateManager).set(
+'list:member:regular:footer', None, 'mailman:///myfooter.txt')
+self._mlist.preferred_language = 'en'
+address = getUtility(IUserManager).create_address(
+'aper...@example.com', 'Anne Person')
+member = Member(MemberRole.member, self._mlist.list_id, address)
+member.preferences = Preferences()
+member.preferences.preferred_language = 'en'
+msgdata = dict(member=member)
+decorate.process(self._mlist, self._msg, msgdata)
+self.assertIn('Anne Person ',
+  self._msg.as_string())
+
+def test_decorate_member_as_user(self):
+site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
+os.makedirs(site_dir)
+footer_path = os.path.join(site_dir, 'myfooter.txt')
+with open(footer_path, 'w', encoding='utf-8') as fp:
+print('$member', file=fp)
+getUtility(ITemplateManager).set(
+'list:member:regular:footer', None, 'mailman:///myfooter.txt')
+self._mlist.preferred_language = 'en'
+user 

[Mailman-checkins] [Branch ~mailman-coders/mailman/2.1] Rev 1745: Removed a Python 2.7 dependency introduced in 2.1.26.

2018-03-01 Thread noreply

revno: 1745
fixes bug: https://launchpad.net/bugs/1752658
committer: Mark Sapiro 
branch nick: 2.1
timestamp: Thu 2018-03-01 09:26:02 -0800
message:
  Removed a Python 2.7 dependency introduced in 2.1.26.
modified:
  Mailman/Cgi/subscribe.py
  NEWS


--
lp:mailman/2.1
https://code.launchpad.net/~mailman-coders/mailman/2.1

Your team Mailman Checkins is subscribed to branch lp:mailman/2.1.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Cgi/subscribe.py'
--- Mailman/Cgi/subscribe.py	2018-01-30 17:36:18 +
+++ Mailman/Cgi/subscribe.py	2018-03-01 17:26:02 +
@@ -151,7 +151,7 @@
 if not captcha_response['success']:
 e_codes = COMMASPACE.join(captcha_response['error-codes'])
 results.append(_('reCAPTCHA validation failed: %(e_codes)s'))
-except urllib2.URLError as e:
+except urllib2.URLError, e:
 e_reason = e.reason
 results.append(_('reCAPTCHA could not be validated: %(e_reason)s'))
 

=== modified file 'NEWS'
--- NEWS	2018-02-04 16:41:19 +
+++ NEWS	2018-03-01 17:26:02 +
@@ -5,6 +5,13 @@
 
 Here is a history of user visible changes to Mailman.
 
+2.1.27 (xx-xxx-)
+
+  Bug fixes and other patches
+
+- A Python 2.7 dependency introduced with the reCAPTCHA feature in 2.1.26
+  has been removed.  (LP: #1752658)
+
 2.1.26 (04-Feb-2018)
 
   Security

___
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org