On 2006-10-26, Jason R. Mastaler <[EMAIL PROTECTED]> wrote:
> Sounds fine to me.  Except that I'd rather see ACTION_EXPIRED_DATED
> extended to support handling multiple ages of dated messages rather
> than new config variables being added.  

Ok.  This is my first crack at this (see below).  I'm a very
inexperienced python programmer.  So I'd really appreciate some
feedback from the TMDA pythoners as to whether or not this is the
right way to do this.

I haven't made it a patch because I think it's clearer what I'm
trying to accomplish without all the extra patch cruft.

Obviously, there's more code for me to add.  I still have to check
if ACTION_EXPIRED_DATED is a string or not and handle each case
differently, but that's easy.  I'm just looking for feedback on
whether or not this is the right direction to go for handling the
multiple expirations.

Thanks,
- Mark


#!/usr/bin/env python

import sys
from TMDA import Util

####  Sample assumptions so that the code will actually work


# dated address expired 'overdue' seconds ago
overdue = Util.seconds(sys.argv[1])

# Sample value for ACTION_EXPIRED_DATED
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

### Below would be done at the very end of verify_dated_cookie() in 
### tmda-rfilter

templist = []

# First, convert the symbolic times into seconds, making 'default' = 0
for k,v in ACTION_EXPIRED_DATED.iteritems():
    if k!='default':
        templist.append((Util.seconds(k),v))
    else:
        templist.append((0,v))

templist.sort()
templist.reverse()

# Now, iterate through values and see where overdue fits on
i=0
while i < len(templist):
        if overdue > templist[i][0]:
                # We've found where it's overdue.  Now we do something about it
                print templist[i][1].lower()
                break

                ### What I'd really do, if this were in the code
                # do_default_action(templist[i][1].lower(), logmsg, 
                #   'bounce_expired_dated.txt')
        i=i+1

_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to