[prev in list] [next in list] [prev in thread] [next in thread]
List: mailman-cvs
Subject: [Mailman-checkins] SF.net SVN: mailman: [8161] trunk/mailman/Mailman
From: tkikuchi () users ! sourceforge ! net
Date: 2007-03-01 2:49:20
Message-ID: E1HMbM8-0000UV-ML () sc8-pr-svn1 ! sourceforge ! net
[Download RAW message or body]
Revision: 8161
http://svn.sourceforge.net/mailman/?rev=8161&view=rev
Author: tkikuchi
Date: 2007-02-28 18:49:20 -0800 (Wed, 28 Feb 2007)
Log Message:
-----------
Restoreing i18n in 2.2
- As the default type of string in mailman-2.2 was set to 'unicode',
i18n codes became need to be fixed.
- Fixed: admin web interface. Other web interfaces needs more verification.
- Fixed: non-digest delivery. Stil to go: digest and archive.
Modified Paths:
--------------
trunk/mailman/Mailman/Cgi/Auth.py
trunk/mailman/Mailman/Cgi/admin.py
trunk/mailman/Mailman/Gui/GUIBase.py
trunk/mailman/Mailman/HTMLFormatter.py
trunk/mailman/Mailman/Handlers/Decorate.py
trunk/mailman/Mailman/Message.py
trunk/mailman/Mailman/SafeDict.py
trunk/mailman/Mailman/Utils.py
trunk/mailman/Mailman/htmlformat.py
trunk/mailman/Mailman/i18n.py
Modified: trunk/mailman/Mailman/Cgi/Auth.py
===================================================================
--- trunk/mailman/Mailman/Cgi/Auth.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Cgi/Auth.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -56,5 +56,5 @@
'path' : actionurl,
'message' : msg,
'who' : who,
- }, mlist=mlist)
- print mlist.GetMailmanFooter()
+ }, mlist=mlist).encode(charset)
+ print mlist.GetMailmanFooter().encode(charset)
Modified: trunk/mailman/Mailman/Cgi/admin.py
===================================================================
--- trunk/mailman/Mailman/Cgi/admin.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Cgi/admin.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -497,7 +497,7 @@
# The very first item in the config info will be treated as a general
# description if it is a string
description = options[0]
- if isinstance(description, str):
+ if isinstance(description, basestring):
table.AddRow([description])
table.AddCellInfo(table.GetCurrentRowIndex(), 0, colspan=2)
options = options[1:]
@@ -514,7 +514,7 @@
width='85%')
for item in options:
- if isinstance(item, str):
+ if isinstance(item, basestring):
# The very first banner option (string in an options list) is
# treated as a general description, while any others are
# treated as section headers - centered and italicized...
@@ -937,8 +937,7 @@
for addr in members:
link = Link(mlist.GetOptionsURL(addr, obscure=1),
mlist.getMemberCPAddress(addr))
- fullname = Utils.uncanonstr(mlist.getMemberName(addr),
- mlist.preferred_language)
+ fullname = mlist.getMemberName(addr)
name = TextBox(addr + '_realname', fullname, size=longest).Format()
cells = [Center(CheckBox(addr + '_unsub', 'off', 0).Format()),
link.Format() + '<br>' +
Modified: trunk/mailman/Mailman/Gui/GUIBase.py
===================================================================
--- trunk/mailman/Mailman/Gui/GUIBase.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Gui/GUIBase.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -42,8 +42,9 @@
# Let ValueErrors propagate
return int(val)
# String and Text widgets both just return their values verbatim
+ # but convert into unicode (for 2.2)
if wtype in (Defaults.String, Defaults.Text):
- return val
+ return unicode(val, Utils.GetCharSet(mlist.preferred_language))
# This widget contains a single email address
if wtype == Defaults.Email:
# BAW: We must allow blank values otherwise reply_to_address can't
Modified: trunk/mailman/Mailman/HTMLFormatter.py
===================================================================
--- trunk/mailman/Mailman/HTMLFormatter.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/HTMLFormatter.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -361,8 +361,8 @@
tag = parts[i].lower()
if replacements.has_key(tag):
repl = replacements[tag]
- if isinstance(repl, type(u'')):
- repl = repl.encode(charset, 'replace')
+ if isinstance(repl, str):
+ repl = unicode(repl, charset, 'replace')
parts[i] = repl
else:
parts[i] = ''
Modified: trunk/mailman/Mailman/Handlers/Decorate.py
===================================================================
--- trunk/mailman/Mailman/Handlers/Decorate.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Handlers/Decorate.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -50,11 +50,11 @@
d['user_password'] = mlist.getMemberPassword(member)
d['user_language'] = mlist.getMemberLanguage(member)
username = mlist.getMemberName(member) or None
- try:
- username = username.encode(Utils.GetCharSet(d['user_language']))
- except (AttributeError, UnicodeError):
- username = member
- d['user_name'] = username
+ #try:
+ # username = username.encode(Utils.GetCharSet(d['user_language']))
+ #except (AttributeError, UnicodeError):
+ # username = member
+ d['user_name'] = username or d['user_delivered_to']
d['user_optionsurl'] = mlist.GetOptionsURL(member)
except Errors.NotAMemberError:
pass
@@ -88,11 +88,9 @@
# MIME multipart chroming the message?
wrap = True
if not msg.is_multipart() and msgtype == 'text/plain':
- # TK: Try to keep the message plain by converting the header/
- # footer/oldpayload into unicode and encode with mcset/lcset.
- # Try to decode qp/base64 also.
- uheader = unicode(header, lcset, 'ignore')
- ufooter = unicode(footer, lcset, 'ignore')
+ # header/footer is now in unicode (2.2)
+ uheader = header
+ ufooter = footer
try:
oldpayload = unicode(msg.get_payload(decode=True), mcset)
frontsep = endsep = u''
@@ -101,20 +99,23 @@
if footer and not oldpayload.endswith('\n'):
endsep = u'\n'
payload = uheader + frontsep + oldpayload + endsep + ufooter
- try:
- # first, try encode with list charset
- payload = payload.encode(lcset)
- newcset = lcset
- except UnicodeError:
- if lcset != mcset:
- # if fail, encode with message charset (if different)
- payload = payload.encode(mcset)
- newcset = mcset
- # if this fails, fallback to outer try and wrap=true
- del msg['content-transfer-encoding']
- del msg['content-type']
- msg.set_payload(payload, newcset)
- wrap = False
+ # Try to set message in list charset then message charset.
+ # Fall back to 'utf-8' if both doesn't work.
+ csets = [lcset,]
+ if mcset != lcset:
+ csets.append(mcset)
+ if 'utf-8' not in csets:
+ csets.append('utf-8')
+ for cset in csets:
+ try:
+ payload = payload.encode(cset)
+ del msg['content-transfer-encoding']
+ del msg['content-type']
+ msg.set_payload(payload, cset)
+ wrap = False
+ break
+ except UnicodeError:
+ continue
except (LookupError, UnicodeError):
pass
elif msg.get_content_type() == 'multipart/mixed':
@@ -124,11 +125,11 @@
if not isinstance(payload, list):
payload = [payload]
if footer:
- mimeftr = MIMEText(footer, 'plain', lcset)
+ mimeftr = MIMEText(footer.encode(lcset), 'plain', lcset)
mimeftr['Content-Disposition'] = 'inline'
payload.append(mimeftr)
if header:
- mimehdr = MIMEText(header, 'plain', lcset)
+ mimehdr = MIMEText(header.encode(lcset), 'plain', lcset)
mimehdr['Content-Disposition'] = 'inline'
payload.insert(0, mimehdr)
msg.set_payload(payload)
@@ -166,11 +167,11 @@
# any).
payload = [inner]
if header:
- mimehdr = MIMEText(header, 'plain', lcset)
+ mimehdr = MIMEText(header.encode(lcset), 'plain', lcset)
mimehdr['Content-Disposition'] = 'inline'
payload.insert(0, mimehdr)
if footer:
- mimeftr = MIMEText(footer, 'plain', lcset)
+ mimeftr = MIMEText(footer.encode(lcset), 'plain', lcset)
mimeftr['Content-Disposition'] = 'inline'
payload.append(mimeftr)
msg.set_payload(payload)
Modified: trunk/mailman/Mailman/Message.py
===================================================================
--- trunk/mailman/Mailman/Message.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Message.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -207,13 +207,14 @@
Message.__init__(self)
charset = None
if lang is not None:
- charset = Charset(Utils.GetCharSet(lang))
+ csetstr = Utils.GetCharSet(lang)
+ charset = Charset(csetstr)
if text is not None:
- self.set_payload(text, charset)
+ self.set_payload(text.encode(csetstr), charset)
if subject is None:
subject = '(no subject)'
- self['Subject'] = Header(subject, charset, header_name='Subject',
- errors='replace')
+ self['Subject'] = Header(subject.encode(csetstr), charset,
+ header_name='Subject', errors='replace')
self['From'] = sender
if isinstance(recip, list):
self['To'] = COMMASPACE.join(recip)
Modified: trunk/mailman/Mailman/SafeDict.py
===================================================================
--- trunk/mailman/Mailman/SafeDict.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/SafeDict.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -15,6 +15,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
+from Mailman.configuration import config
+
"""A `safe' dictionary for string interpolation."""
COMMASPACE = ', '
@@ -28,6 +30,15 @@
This is used in maketext so that editing templates is a bit more robust.
"""
+ def __init__(self, d='', charset=None, lang=None):
+ super(SafeDict, self).__init__(d)
+ if charset:
+ self.cset = charset
+ elif lang:
+ self.cset = config.LC_DESCRIPTIONS[lang][1]
+ else:
+ self.cset = 'us-ascii'
+
def __getitem__(self, key):
try:
return super(SafeDict, self).__getitem__(key)
@@ -38,6 +49,9 @@
return '<Missing key: %s>' % `key`
def interpolate(self, template):
+ for k, v in self.items():
+ if isinstance(v, str):
+ self.__setitem__(k, unicode(v, self.cset))
return template % self
Modified: trunk/mailman/Mailman/Utils.py
===================================================================
--- trunk/mailman/Mailman/Utils.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/Utils.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -503,16 +503,12 @@
raise IOError(errno.ENOENT, 'No template file found', templatefile)
template = fp.read()
fp.close()
+ template = unicode(template, GetCharSet(lang), 'replace')
text = template
if dict is not None:
try:
- sdict = SafeDict(dict)
- try:
- text = sdict.interpolate(template)
- except UnicodeError:
- # Try again after coercing the template to unicode
- utemplate = unicode(template, GetCharSet(lang), 'replace')
- text = sdict.interpolate(utemplate)
+ sdict = SafeDict(dict, lang=lang)
+ text = sdict.interpolate(template)
except (TypeError, ValueError), e:
# The template is really screwed up
log.error('broken template: %s\n%s', filename, e)
Modified: trunk/mailman/Mailman/htmlformat.py
===================================================================
--- trunk/mailman/Mailman/htmlformat.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/htmlformat.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -325,7 +325,7 @@
if not self.suppress_head:
output.append('%s</BODY>' % tab)
output.append('%s</HTML>' % tab)
- return NL.join(output)
+ return NL.join(output).encode(charset, 'replace')
def addError(self, errmsg, tag=None):
if tag is None:
Modified: trunk/mailman/Mailman/i18n.py
===================================================================
--- trunk/mailman/Mailman/i18n.py 2007-02-22 11:02:21 UTC (rev 8160)
+++ trunk/mailman/Mailman/i18n.py 2007-03-01 02:49:20 UTC (rev 8161)
@@ -112,7 +112,9 @@
# Are we using $-strings or %-strings?
if use_templates:
return Template(tns).safe_substitute(attrdict(d))
- return tns % SafeDict(d)
+ if type(tns) == str:
+ tns = unicode(tns, charset)
+ return SafeDict(d, charset=charset).interpolate(tns)
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site. _______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/mailman-cvs%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic