Update of /cvsroot/mailman/mailman/cron
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18090/cron
Modified Files:
Tag: Release_2_1-maint
checkdbs
Log Message:
[ 790494 ] built-in automatic discard
Index: checkdbs
===================================================================
RCS file: /cvsroot/mailman/mailman/cron/checkdbs,v
retrieving revision 2.17.2.3
retrieving revision 2.17.2.4
diff -u -d -r2.17.2.3 -r2.17.2.4
--- checkdbs 26 Dec 2003 22:51:10 -0000 2.17.2.3
+++ checkdbs 8 Oct 2004 12:38:49 -0000 2.17.2.4
@@ -52,6 +52,8 @@
_ = i18n._
i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
+now = time.time()
+
def usage(code, msg=''):
@@ -99,16 +101,24 @@
if count:
i18n.set_language(mlist.preferred_language)
realname = mlist.real_name
- text = Utils.maketext(
- 'checkdbs.txt',
- {'count' : count,
- 'host_name': mlist.host_name,
- 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
- 'real_name': realname,
- }, mlist=mlist)
- text += '\n' + pending_requests(mlist)
+ discarded = auto_discard(mlist)
+ if discarded:
+ count = count - discarded
+ text = _(
+ 'Notice: %(discarded)d old request(s) automatically expired.\n\n')
+ else:
+ text = ''
+ if count:
+ text += Utils.maketext(
+ 'checkdbs.txt',
+ {'count' : count,
+ 'host_name': mlist.host_name,
+ 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
+ 'real_name': realname,
+ }, mlist=mlist)
+ text += '\n' + pending_requests(mlist)
subject = _(
- '%(count)d %(realname)s moderator request(s) waiting')
+ '%(realname)s moderator requests notice')
msg = Message.UserNotification(mlist.GetOwnerEmail(),
mlist.GetBouncesEmail(),
subject, text,
@@ -121,6 +131,7 @@
def pending_requests(mlist):
+ lcset = Utils.GetCharSet(mlist.preferred_language)
# Must return a byte string
lcset = Utils.GetCharSet(mlist.preferred_language)
pending = []
@@ -172,6 +183,18 @@
utext = unicode(text, incodec, 'replace')
return utext.encode(outcodec, 'replace')
+def auto_discard(mlist):
+ # Discard old held messages
+ discard_count = 0
+ expire = mlist.max_days_to_hold * 86400 # days
+ heldmsgs = mlist.GetHeldMessageIds()
+ if expire and len(heldmsgs):
+ for id in heldmsgs:
+ if now - mlist.GetRecord(id)[0] > expire:
+ mlist.HandleRequest(id, mm_cfg.DISCARD)
+ discard_count += 1
+ mlist.Save()
+ return discard_count
if __name__ == '__main__':
_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org