Yasuhito FUTATSUKI at POEM has proposed merging
lp:~futatuki/mailman/enhance-i18n-list-overview into lp:mailman/2.1.
Commit message:
enhance i18n of listinfo/admin overview page
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~futatuki/mailman/enhance-i18n-list-overview/+merge/348365
On listinfo/admin overview page, lists' description may be stored in different
charset/encoding from what the page uses. However current implementation of
listinfo/admin overview page uses those regardlessly of the difference, so
those cannot be displayed correctly.
To avoid this, (1) I've implemented a new function to get description as string
of specified charset (with XML character reference) in MailList class,
MailList.GetDescription(), and use it instead of accessing .description
attribute directly in overview functions.
This function uses a precondition that .description attribute is stored in
charset of list's preferred_language. This is fundamentally true, but in case
list's preferred_language has been changed and of the description hasn't, it is
not true(Suppose changing preferred_language temporary to edit template files
via Web UI, for example). To help to ensure the precondition, (2) I've added
hook to change charset of list's description when preferred_language is changed
via Web UI. (This is not always preserve identity of description string when
preferred_languages is changed one of other charset/encoding and then changed
back, because of multiple mapping of character between charset, and intentional
use of XML character reference)
--
Your team Mailman Coders is requested to review the proposed merge of
lp:~futatuki/mailman/enhance-i18n-list-overview into lp:mailman/2.1.
=== modified file 'Mailman/Cgi/admin.py'
--- Mailman/Cgi/admin.py 2018-06-18 11:35:51 +0000
+++ Mailman/Cgi/admin.py 2018-06-21 22:07:08 +0000
@@ -295,7 +295,7 @@
else:
advertised.append((mlist.GetScriptURL('admin'),
mlist.real_name,
- mlist.description))
+ mlist.GetDescription()))
# Greeting depends on whether there was an error or not
if msg:
greeting = FontAttr(msg, color="ff5060", size="+1")
=== modified file 'Mailman/Cgi/listinfo.py'
--- Mailman/Cgi/listinfo.py 2018-06-03 20:19:49 +0000
+++ Mailman/Cgi/listinfo.py 2018-06-21 22:07:08 +0000
@@ -114,7 +114,7 @@
else:
advertised.append((mlist.GetScriptURL('listinfo'),
mlist.real_name,
- Utils.websafe(mlist.description)))
+ Utils.websafe(mlist.GetDescription())))
if msg:
greeting = FontAttr(msg, color="ff5060", size="+1")
else:
=== modified file 'Mailman/Gui/GUIBase.py'
--- Mailman/Gui/GUIBase.py 2018-05-21 18:37:57 +0000
+++ Mailman/Gui/GUIBase.py 2018-06-21 22:07:08 +0000
@@ -138,6 +138,14 @@
def _setValue(self, mlist, property, val, doc):
# Set the value, or override to take special action on the property
if not property.startswith('_') and getattr(mlist, property) <> val:
+ if property == 'preferred_language':
+ ocs = Utils.GetCharSet(getattr(mlist, property)) or 'us-ascii'
+ ncs = Utils.GetCharSet(val) or 'us-ascii'
+ odesc = getattr(mlist, 'description')
+ if ocs != ncs and not isinstance(odesc, unicode):
+ setattr(mlist, 'description',
+ Utils.xml_to_unicode(odesc, ocs).encode(
+ ncs, 'xmlcharrefreplace'))
setattr(mlist, property, val)
def _postValidate(self, mlist, doc):
=== modified file 'Mailman/MailList.py'
--- Mailman/MailList.py 2018-06-18 11:35:51 +0000
+++ Mailman/MailList.py 2018-06-21 22:07:08 +0000
@@ -262,6 +262,27 @@
user = Utils.ObscureEmail(user)
return '%s/%s' % (url, urllib.quote(user.lower()))
+ def GetDescription(self, cset=None, errors='xmlcharrefreplace'):
+ # Get list's description in charset specified by cset.
+ # If cset is None, it uses charset of context language.
+ mcset = Utils.GetCharSet(self.preferred_language)
+ if cset is None:
+ # translation context may not be initialized
+ trns = i18n.get_translation()
+ if trns is None:
+ ccset = 'us-ascii'
+ else:
+ ccset = i18n.get_translation().charset() or 'us-ascii'
+ else:
+ ccset = cset
+ if isinstance(self.description, unicode):
+ return self.description.encode(ccset, errors)
+ if mcset == ccset:
+ return self.description
+ return Utils.xml_to_unicode(self.description, mcset).encode(ccset,
+ errors)
+
+
#
# Instance and subcomponent initialization
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders