Merge lp:~futatuki/mailman/enhance-i18n-list-overview into lp:mailman/2.1

Proposed by Yasuhito FUTATSUKI at POEM
Status: Merged
Merged at revision: 1782
Proposed branch: lp:~futatuki/mailman/enhance-i18n-list-overview
Merge into: lp:mailman/2.1
Diff against target: 79 lines (+29/-3)
4 files modified
Mailman/Cgi/ (+1/-1)
Mailman/Cgi/ (+1/-1)
Mailman/ (+6/-1)
Mailman/ (+21/-0)
To merge this branch: bzr merge lp:~futatuki/mailman/enhance-i18n-list-overview
Reviewer Review Type Date Requested Status
Mark Sapiro code Needs Information
Review via email:

Commit message

enhance i18n of listinfo/admin overview page

Description of the change

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)

To post a comment you must log in.
Revision history for this message
Mark Sapiro (msapiro) wrote :

In your change to Mailman/Cgi/, mlist.GetDescription() should be Utils.websafe(mlist.GetDescription()). I know it isn't currently websafed, but it should be.

I understand the need for the changes to and because the overview page is in the charset of the site's preferred language and the description may not be.

There is also another issue in the listinfo for a specific list. Here the <mm-list-description> replacement puts the description at the top of the page and the page can be viewed in a language other than the list default, so I think Mailman/ needs to also be changed to use GetDescription() for the <mm-list-description> replacement.

Finally though, I don't understand the need for the change to Mailman/Gui/ since there we are dealing with changes via the admin CGI for a list and the admin UI should be in the list's preferred language charset always. Am I missing something here?

review: Needs Information (code)
Revision history for this message
Mark Sapiro (msapiro) wrote :

I've looked a bit more carefully and I now see that the change to Mailman/Gui/ is to recode mlist.description if the list's preferred language is changed. This is probably useful, but it is incomplete as there are several other strings encoded in the charset of the list's preferred language such as and the message and digest headers and footers.

This is what makes it difficult to change Mailman's character set for a language. See the recode(), doitem() and convert() functions in Mailman/ for more on this.

I'm not sure it's worth the effort to try to do this automatically if the list's preferred language is changed.

Revision history for this message
Mark Sapiro (msapiro) wrote :

It would have helped if I had actually fully read your description before commenting based on my reading of the diff.

In any case, at this point, I agree with the changes to and and the new GetDescription() method, and I think a change to would also be good, but I don't think I want to do the recoding on preferred language change.

Also, I had planned on a 2.1.27 release tomorrow, and I don't want to delay that too much.

Revision history for this message
Yasuhito FUTATSUKI at POEM (futatuki) wrote :

I've also thought the change of Gui/ is optional, and I understand the dificulty. So I agree with drop it.

1783. By Yasuhito FUTATSUKI at POEM

* apply Utils.websafe() to description string in
* Use GetDescription() in

1784. By Yasuhito FUTATSUKI at POEM

revert Mailman/Gui/ to drop change of this branch

Revision history for this message
Yasuhito FUTATSUKI at POEM (futatuki) wrote :

Now I've fixed the matter you pointed out.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Mailman/Cgi/'
2--- Mailman/Cgi/ 2018-06-18 11:35:51 +0000
3+++ Mailman/Cgi/ 2018-06-22 00:40:28 +0000
4@@ -295,7 +295,7 @@
5 else:
6 advertised.append((mlist.GetScriptURL('admin'),
7 mlist.real_name,
8- mlist.description))
9+ Utils.websafe(mlist.GetDescription())))
10 # Greeting depends on whether there was an error or not
11 if msg:
12 greeting = FontAttr(msg, color="ff5060", size="+1")
14=== modified file 'Mailman/Cgi/'
15--- Mailman/Cgi/ 2018-06-03 20:19:49 +0000
16+++ Mailman/Cgi/ 2018-06-22 00:40:28 +0000
17@@ -114,7 +114,7 @@
18 else:
19 advertised.append((mlist.GetScriptURL('listinfo'),
20 mlist.real_name,
21- Utils.websafe(mlist.description)))
22+ Utils.websafe(mlist.GetDescription())))
23 if msg:
24 greeting = FontAttr(msg, color="ff5060", size="+1")
25 else:
27=== modified file 'Mailman/'
28--- Mailman/ 2018-06-17 23:47:34 +0000
29+++ Mailman/ 2018-06-22 00:40:28 +0000
30@@ -389,11 +389,16 @@
31 listlangs = _(Utils.GetLanguageDescr(self.preferred_language))
32 else:
33 listlangs = self.GetLangSelectBox(lang).Format()
34+ if lang:
35+ cset = Utils.GetCharSet(lang) or 'us-ascii'
36+ else:
37+ cset = Utils.GetCharSet(self.preferred_language) or 'us-ascii'
38 d = {
39 '<mm-mailman-footer>' : self.GetMailmanFooter(),
40 '<mm-list-name>' : self.real_name,
41 '<mm-email-user>' : self._internal_name,
42- '<mm-list-description>' : Utils.websafe(self.description),
43+ '<mm-list-description>' :
44+ Utils.websafe(self.GetDescription(cset)),
45 '<mm-list-info>' :
46 '<!---->' + BR.join( + '<!---->',
47 '<mm-form-end>' : self.FormatFormEnd(),
49=== modified file 'Mailman/'
50--- Mailman/ 2018-06-18 11:35:51 +0000
51+++ Mailman/ 2018-06-22 00:40:28 +0000
52@@ -262,6 +262,27 @@
53 user = Utils.ObscureEmail(user)
54 return '%s/%s' % (url, urllib.quote(user.lower()))
56+ def GetDescription(self, cset=None, errors='xmlcharrefreplace'):
57+ # Get list's description in charset specified by cset.
58+ # If cset is None, it uses charset of context language.
59+ mcset = Utils.GetCharSet(self.preferred_language)
60+ if cset is None:
61+ # translation context may not be initialized
62+ trns = i18n.get_translation()
63+ if trns is None:
64+ ccset = 'us-ascii'
65+ else:
66+ ccset = i18n.get_translation().charset() or 'us-ascii'
67+ else:
68+ ccset = cset
69+ if isinstance(self.description, unicode):
70+ return self.description.encode(ccset, errors)
71+ if mcset == ccset:
72+ return self.description
73+ return Utils.xml_to_unicode(self.description, mcset).encode(ccset,
74+ errors)
79 #
80 # Instance and subcomponent initialization


People subscribed via source and target branches

to status/vote changes: