diff options
| author | bwarsaw | 2001-05-01 06:29:48 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-05-01 06:29:48 +0000 |
| commit | 7aae23fba21fb5abd36259c0ba2dcfef5180f087 (patch) | |
| tree | 336e0031808af5fc82ad9eb988dfa22534b97373 /Mailman/Handlers/ToDigest.py | |
| parent | 3bff39a37563d61a88ea8240969651a4f01079fc (diff) | |
| download | mailman-7aae23fba21fb5abd36259c0ba2dcfef5180f087.tar.gz mailman-7aae23fba21fb5abd36259c0ba2dcfef5180f087.tar.zst mailman-7aae23fba21fb5abd36259c0ba2dcfef5180f087.zip | |
mimelib's ReprMixin class and module was renamed to StringableMixin in
the 0.3 release. This means you must download and install the 0.3
version of mimelib to work with the current CVS snapshot!
ReprMIME => StringableMIME
send_digests(): Added support for auto-bumping of digest volume
numbers based on the digest_volume_frequency configuration attribute.
send_i18n_digests(): After creating the mimedigest container, set its
payload to the empty list. This ensures that subsequent
add_payload()s will succeed. mimelib 0.3 will raise an exception
otherwise when appending to a scalar payload.
Diffstat (limited to 'Mailman/Handlers/ToDigest.py')
| -rw-r--r-- | Mailman/Handlers/ToDigest.py | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index e83651f24..9ecf317c3 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -27,6 +27,7 @@ import os import re +import time from types import ListType from mimelib.Parser import Parser @@ -34,7 +35,7 @@ from mimelib.Generator import Generator from mimelib.MIMEBase import MIMEBase from mimelib.Text import Text from mimelib.address import getaddresses -from mimelib.ReprMixin import ReprMixin +from mimelib.StringableMixin import StringableMixin from Mailman import mm_cfg from Mailman import Utils @@ -97,12 +98,41 @@ def msgfactory(fp): # We want mimelib's MIMEBase class, but we also want a str() able object. -class ReprMIME(MIMEBase, ReprMixin): +class StringableMIME(MIMEBase, StringableMixin): pass def send_digests(mlist, mboxfp): + # Set the digest volume and time + if mlist.digest_last_sent_at: + bump = 0 + # See if we should bump the digest volume number + timetup = time.localtime(mlist.digest_last_sent_at) + now = time.localtime(time.time()) + freq = mlist.digest_volume_frequency + if freq == 0 and timetup[0] < now[0]: + bump = 1 # Yearly + elif freq == 1 and timetup[1] <> now[1]: + # Monthly, but we take a cheap way to calculate this. We assume + # that the clock isn't going to be reset backwards. + bump = 1 + elif freq == 2 and (timetup[1] % 4 <> now[1] % 4): + # Quarterly, same caveat + bump = 1 + elif freq == 3: + # Once again, take a cheap way of calculating this + weeknum_last = int(time.strftime('%W', timetup)) + weeknum_now = int(time.strftime('%W', now)) + if weeknum_now > weeknum_last or timetup[0] > now[0]: + bump = 1 + elif timetup[7] <> now[7]: + # assume daily + bump = 1 + if bump: + mlist.volume += 1 + mlist.next_digest_number = 1 + mlist.digest_last_sent_at = time.time() # Wrapper around actually digest crafter to set up the language context # properly. All digests are translated to the list's preferred language. otranslation = i18n.get_translation() @@ -124,7 +154,7 @@ def send_i18n_digests(mlist, mboxfp): digestid = _('%(realname)s Digest, Vol %(volume)d, Issue %(issue)d') # Set things up for the MIME digest. Only headers not added by # CookHeaders need be added here. - mimemsg = ReprMIME('multipart', 'mixed') + mimemsg = StringableMIME('multipart', 'mixed') mimemsg['From'] = mlist.GetRequestEmail() mimemsg['Subject'] = digestid mimemsg['To'] = mlist.GetListEmail() @@ -250,6 +280,7 @@ def send_i18n_digests(mlist, mboxfp): print >> plainmsg # Now go through and add each message mimedigest = MIMEBase('multipart', 'digest') + mimedigest.set_payload([]) mimemsg.add_payload(mimedigest) first = 1 for msg in messages: |
