On 2006-10-28, Jason R. Mastaler <[EMAIL PROTECTED]> wrote:
> Take a look at tmda-filter vs. tmda-rfilter. tmda-filter is just a
> wrapper whose purpose is to catch and log any and all uncaught
> exceptions, and then defer the delivery.
Ok. Given that, here's an updated patch that handles these
conditions:
* if no 'default' specified, assume 'confirm' (maybe instead raise
an exception?)
* if ACTION_EXPIRED_DATED is neither a string nor a dictionary,
raise TypeError
Any other suggested improvements?
Thanks,
- Mark
Index: TMDA/ChangeLog
===================================================================
--- TMDA/ChangeLog (revision 2114)
+++ TMDA/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2006-10-07 Mark Horn <[EMAIL PROTECTED]>
+
+ * Defaults.py: added additional descriptino to ACTION_EXPIRED_DATED
+
2006-10-07 Jason R. Mastaler <[EMAIL PROTECTED]>
* pythonlib/email: Sync up with email 4.0.1.
Index: TMDA/Defaults.py
===================================================================
--- TMDA/Defaults.py (revision 2114)
+++ TMDA/Defaults.py (working copy)
@@ -681,7 +681,16 @@
# "hold"
# silently hold message in pending queue
#
-# Default is confirm
+# This can also be a Python Dictionary to specify multiple ways of handling
+# expiration types. For example:
+#
+# ACTION_EXPIRED_DATED = {
+# 'default':'confirm', ## default is to confirm, unless
+# '1w': 'bounce', ## ...it expired more than 1w ago, then bounce
+# '30d': 'hold', ## ...it expired more than 30d ago, then hold
+# '1Y': 'drop'} ## ...it expired more than 1Y ago, then drop
+#
+# Default is "confirm"
if not vars().has_key('ACTION_EXPIRED_DATED'):
ACTION_EXPIRED_DATED = "confirm"
Index: bin/ChangeLog
===================================================================
--- bin/ChangeLog (revision 2114)
+++ bin/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2006-10-27 Mark Horn <[EMAIL PROTECTED]>
+
+ * tmda-rfilter: added multiple expiration to ACTION_EXPIRED_DATED
+
2006-10-13 Jason R. Mastaler <[EMAIL PROTECTED]>
* tmda-rfilter: Migrate from getopt to optparse.
Index: bin/tmda-rfilter
===================================================================
--- bin/tmda-rfilter (revision 2114)
+++ bin/tmda-rfilter (working copy)
@@ -469,6 +469,7 @@
bouncegen('request')
+
def release_pending(timestamp, pid, msg):
"""Release a confirmed message from the pending queue."""
# Remove Return-Path: to avoid duplicates.
@@ -578,7 +579,41 @@
del msgin['x-tmda-confirm-done']
mta.deliver(msgin)
+def dispose_expired_dated(cookie_date):
+ """Dispoose of an expired dated address based on ACTION_EXPIRED_DATED
+ dictionary settings"""
+ templist = []
+
+ havedefault = 0
+
+ for k,v in Defaults.ACTION_EXPIRED_DATED.iteritems():
+ if k != 'default':
+ templist.append((Util.seconds(k),v,k))
+ else:
+ templist.append((0,v,k))
+ havedefault = 1
+
+ if havedefault == 0:
+# raise ValueError, 'No default specified for ACTION_EXPIRED_DATED'
+ templist.append((0,'confirm','default'))
+
+ templist.sort()
+ templist.reverse()
+
+ overdue = int('%d' % time.time()) - int(cookie_date)
+
+ i = 0
+ while i < len(templist):
+ if overdue > templist[i][0]:
+ logmsg = "action_expired_dated/%s (%s)" % \
+ (templist[i][2],
+ Util.make_date(int(cookie_date)))
+ do_default_action(templist[i][1].lower(), logmsg,
+ 'bounce_expired_dated.txt')
+ i = i + 1
+
+
def verify_dated_cookie(dated_cookie):
"""Verify a dated cookie."""
# Save some time if the cookie is bogus.
@@ -602,10 +637,17 @@
else:
logmsg = "action_expired_dated (%s)" % \
Util.make_date(int(cookie_date))
- do_default_action(Defaults.ACTION_EXPIRED_DATED.lower(),
+ if type(Defaults.ACTION_EXPIRED_DATED) == str:
+ do_default_action(Defaults.ACTION_EXPIRED_DATED.lower(),
logmsg, 'bounce_expired_dated.txt')
+ elif type(Defaults.ACTION_EXPIRED_DATED) != dict:
+ raise TypeError, 'ACTION_EXPIRED_DATED is wrong type. ' + \
+ 'Must be string or dictionary'
+ else:
+ dispose_expired_dated(cookie_date)
+
def verify_sender_cookie(sender_address,sender_cookie):
"""Verify a sender cookie."""
try:
_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers