Revision: 8163
          http://svn.sourceforge.net/mailman/?rev=8163&view=rev
Author:   tkikuchi
Date:     2007-03-02 04:36:15 -0800 (Fri, 02 Mar 2007)

Log Message:
-----------
Fixes for i18n digest to work.

Mailman/Queue/Switchboard.py:
    listname is returned in unicode.
    ( '\x80' + 'a' is OK, '\x80' + u'a' is NG)
Mailman/Utils.py:
    Utils.oneline() is extended for returning unicode string.
Mailman/Digester.py:
    next_post_number is not used anywhere.
Mailman/database/listdata.py:
    Attributes added (esp. for non web u/i)
Mailman/bin/senddigests.py:
    Initialization
Mailman/Handlers/ToDigest.py:
    Internal string calculation is done in unicode.  So, several fixes.
    StringIO is used because cStringIO doesn't have encoding attribute.

Modified Paths:
--------------
    trunk/mailman/Mailman/Digester.py
    trunk/mailman/Mailman/Handlers/ToDigest.py
    trunk/mailman/Mailman/Queue/Switchboard.py
    trunk/mailman/Mailman/Utils.py
    trunk/mailman/Mailman/bin/senddigests.py
    trunk/mailman/Mailman/database/listdata.py

Modified: trunk/mailman/Mailman/Digester.py
===================================================================
--- trunk/mailman/Mailman/Digester.py   2007-03-02 00:07:43 UTC (rev 8162)
+++ trunk/mailman/Mailman/Digester.py   2007-03-02 12:36:15 UTC (rev 8163)
@@ -37,7 +37,6 @@
         self.mime_is_default_digest = config.DEFAULT_MIME_IS_DEFAULT_DIGEST
         self.digest_size_threshhold = config.DEFAULT_DIGEST_SIZE_THRESHHOLD
         self.digest_send_periodic = config.DEFAULT_DIGEST_SEND_PERIODIC
-        self.next_post_number = 1
         self.digest_header = config.DEFAULT_DIGEST_HEADER
         self.digest_footer = config.DEFAULT_DIGEST_FOOTER
         self.digest_volume_frequency = config.DEFAULT_DIGEST_VOLUME_FREQUENCY

Modified: trunk/mailman/Mailman/Handlers/ToDigest.py
===================================================================
--- trunk/mailman/Mailman/Handlers/ToDigest.py  2007-03-02 00:07:43 UTC (rev 
8162)
+++ trunk/mailman/Mailman/Handlers/ToDigest.py  2007-03-02 12:36:15 UTC (rev 
8163)
@@ -31,7 +31,7 @@
 import time
 import logging
 
-from cStringIO import StringIO
+from StringIO import StringIO
 from email.Charset import Charset
 from email.Generator import Generator
 from email.Header import decode_header, make_header, Header
@@ -162,6 +162,8 @@
     mimemsg['Message-ID'] = Utils.unique_message_id(mlist)
     # Set things up for the rfc1153 digest
     plainmsg = StringIO()
+    # cStringIO doesn't have encoding. Sigh.
+    plainmsg.encoding = 'utf-8'
     rfc1153msg = Message.Message()
     rfc1153msg['From'] = mlist.GetRequestEmail()
     rfc1153msg['Subject'] = digestsubj
@@ -184,7 +186,7 @@
          'got_owner_email':   mlist.GetOwnerEmail(),
          }, mlist=mlist)
     # MIME
-    masthead = MIMEText(mastheadtxt, _charset=lcset)
+    masthead = MIMEText(mastheadtxt.encode(lcset), _charset=lcset)
     masthead['Content-Description'] = digestid
     mimemsg.attach(masthead)
     # RFC 1153
@@ -194,7 +196,7 @@
     if mlist.digest_header:
         headertxt = decorate(mlist, mlist.digest_header, _('digest header'))
         # MIME
-        header = MIMEText(headertxt, _charset=lcset)
+        header = MIMEText(headertxt.encode(lcset), _charset=lcset)
         header['Content-Description'] = _('Digest Header')
         mimemsg.attach(header)
         # RFC 1153
@@ -208,6 +210,7 @@
     #
     # Meanwhile prepare things for the table of contents
     toc = StringIO()
+    toc.encoding = 'utf-8'
     print >> toc, _("Today's Topics:\n")
     # Now cruise through all the messages in the mailbox of digest messages,
     # building the MIME payload and core of the RFC 1153 digest.  We'll also
@@ -224,14 +227,15 @@
         messages.append(msg)
         # Get the Subject header
         msgsubj = msg.get('subject', _('(no subject)'))
-        subject = Utils.oneline(msgsubj, lcset)
+        subject = Utils.oneline(msgsubj, in_unicode=True)
         # Don't include the redundant subject prefix in the toc
         mo = re.match('(re:? *)?(%s)' % re.escape(mlist.subject_prefix),
                       subject, re.IGNORECASE)
         if mo:
             subject = subject[:mo.start(2)] + subject[mo.end(2):]
         username = ''
-        addresses = getaddresses([Utils.oneline(msg.get('from', ''), lcset)])
+        addresses = getaddresses([Utils.oneline(msg.get('from', ''),
+                                                in_unicode=True)])
         # Take only the first author we find
         if isinstance(addresses, list) and addresses:
             username = addresses[0][0]
@@ -287,7 +291,7 @@
         return
     toctext = toc.getvalue()
     # MIME
-    tocpart = MIMEText(toctext, _charset=lcset)
+    tocpart = MIMEText(toctext.encode(lcset), _charset=lcset)
     tocpart['Content-Description']= _("Today's Topics (%(msgcount)d messages)")
     mimemsg.attach(tocpart)
     # RFC 1153
@@ -319,7 +323,8 @@
         # Honor the default setting
         for h in config.PLAIN_DIGEST_KEEP_HEADERS:
             if msg[h]:
-                uh = Utils.wrap('%s: %s' % (h, Utils.oneline(msg[h], lcset)))
+                uh = Utils.wrap('%s: %s' % (h, Utils.oneline(msg[h],
+                                                             in_unicode=True)))
                 uh = '\n\t'.join(uh.split('\n'))
                 print >> plainmsg, uh
         print >> plainmsg
@@ -344,7 +349,7 @@
     if mlist.digest_footer:
         footertxt = decorate(mlist, mlist.digest_footer, _('digest footer'))
         # MIME
-        footer = MIMEText(footertxt, _charset=lcset)
+        footer = MIMEText(footertxt.encode(lcset), _charset=lcset)
         footer['Content-Description'] = _('Digest Footer')
         mimemsg.attach(footer)
         # RFC 1153
@@ -397,7 +402,7 @@
                     listname=mlist.fqdn_listname,
                     isdigest=True)
     # RFC 1153
-    rfc1153msg.set_payload(plainmsg.getvalue(), lcset)
+    rfc1153msg.set_payload(plainmsg.getvalue().encode(lcset), lcset)
     virginq.enqueue(rfc1153msg,
                     recips=plainrecips,
                     listname=mlist.fqdn_listname,

Modified: trunk/mailman/Mailman/Queue/Switchboard.py
===================================================================
--- trunk/mailman/Mailman/Queue/Switchboard.py  2007-03-02 00:07:43 UTC (rev 
8162)
+++ trunk/mailman/Mailman/Queue/Switchboard.py  2007-03-02 12:36:15 UTC (rev 
8163)
@@ -94,7 +94,7 @@
         else:
             protocol = 0
             msgsave = cPickle.dumps(str(_msg), protocol)
-        hashfood = msgsave + listname + `now`
+        hashfood = msgsave + str(listname) + `now`
         # Encode the current time into the file name for FIFO sorting in
         # files().  The file name consists of two parts separated by a `+':
         # the received time for this message (i.e. when it first showed up on

Modified: trunk/mailman/Mailman/Utils.py
===================================================================
--- trunk/mailman/Mailman/Utils.py      2007-03-02 00:07:43 UTC (rev 8162)
+++ trunk/mailman/Mailman/Utils.py      2007-03-02 12:36:15 UTC (rev 8163)
@@ -826,13 +826,16 @@
     return str(EMPTYSTRING.join(a))
 
 
-def oneline(s, cset):
+def oneline(s, cset='us-ascii', in_unicode=False):
     # Decode header string in one line and convert into specified charset
     try:
         h = email.Header.make_header(email.Header.decode_header(s))
         ustr = h.__unicode__()
         line = UEMPTYSTRING.join(ustr.splitlines())
-        return line.encode(cset, 'replace')
+        if in_unicode:
+            return line
+        else:
+            return line.encode(cset, 'replace')
     except (LookupError, UnicodeError, ValueError, HeaderParseError):
         # possibly charset problem. return with undecoded string in one line.
         return EMPTYSTRING.join(s.splitlines())

Modified: trunk/mailman/Mailman/bin/senddigests.py
===================================================================
--- trunk/mailman/Mailman/bin/senddigests.py    2007-03-02 00:07:43 UTC (rev 
8162)
+++ trunk/mailman/Mailman/bin/senddigests.py    2007-03-02 12:36:15 UTC (rev 
8163)
@@ -23,6 +23,7 @@
 from Mailman import Version
 from Mailman.configuration import config
 from Mailman.i18n import _
+from Mailman.initialize import initialize
 
 # Work around known problems with some RedHat cron daemons
 import signal
@@ -57,7 +58,7 @@
 
 def main():
     opts, args, parser = parseargs()
-    config.load(opts.config)
+    initialize(opts.config)
 
     for listname in set(opts.listnames or Utils.list_names()):
         mlist = MailList.MailList(listname, lock=False)

Modified: trunk/mailman/Mailman/database/listdata.py
===================================================================
--- trunk/mailman/Mailman/database/listdata.py  2007-03-02 00:07:43 UTC (rev 
8162)
+++ trunk/mailman/Mailman/database/listdata.py  2007-03-02 12:36:15 UTC (rev 
8163)
@@ -29,6 +29,15 @@
         Column('list_name',                 Unicode),
         Column('web_page_url',              Unicode),
         Column('admin_member_chunksize',    Integer),
+        Column('next_request_id',           Integer),
+        Column('next_digest_number',        Integer),
+        Column('admin_responses',           PickleType),
+        Column('postings_responses',        PickleType),
+        Column('request_responses',         PickleType),
+        Column('digest_last_sent_at',       Float),
+        Column('one_last_digest',           PickleType),
+        Column('volume',                    Integer),
+        Column('last_post_time',            Float),
         # OldStyleMemberships attributes, temporarily stored as pickles.
         Column('bounce_info',           PickleType),
         Column('delivery_status',       PickleType),
@@ -106,6 +115,7 @@
         Column('member_moderation_action',                      Boolean),
         Column('member_moderation_notice',                      Unicode),
         Column('mime_is_default_digest',                        Boolean),
+        Column('mod_password',                                  Unicode),
         Column('moderator',                                     PickleType),
         Column('msg_footer',                                    Unicode),
         Column('msg_header',                                    Unicode),


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to