"Jason R. Mastaler" <[EMAIL PROTECTED]> writes: > "Jason R. Mastaler" <[EMAIL PROTECTED]> writes: > > > 2. Multiple delivery destination support for both DELIVERY, and in the > > incoming filter file. See tmda-workers archive for discussion > > about syntax, implementation, etc. > > http://mla.libertine.org/tmda-workers/2003-01/msg00033.html > > [...] > > > 4. Multiple actions in an incoming filter file line. e.g, > > > > from [EMAIL PROTECTED] bounce=warning.txt, deliver=~/Maildir/ > > > > See the ``Performing multiple actions'' thread starting at > > http://mla.libertine.org/tmda-workers/2003-01/msg00033.html > > Welp, we're getting closer. Just these two left to finish.
At the end of July we had a brief discussion about the syntax necessary for item 4. We decided to explicitly mention each action, meaning that if the user wants to deliver to an mbox, for example /var/spool/shared, and to his local ~/Maildir, the syntax would be like this: <source> <match> deliver=/var/spool/shared, deliver=~/Maildir/ See http://mla.libertine.org/tmda-workers/2003-07/msg00089.html Given that syntax, item 2 is really just a subset of item 4, so I decided to do 4, since that automatically gives us 2. I've completed the changes to FilterParser. It was soooooo much easier than I had feared. I think the harder part will be wiring it into the rest of TMDA. Anyhow, mind-bogglingly, it actually works in the parser. Here's an excerpt from the FilterParser.__parserule docstring. actions - dictionary: a dictionary with a key of 'action' and a value that is a tuple. Incoming actions have a key of 'action' and the value is a tuple containing any optional parameters (delivery location, bounce template, etc.). Because an action can be specified more than once and there are synonyms for certain actions, the following is possible: deliver=&[EMAIL PROTECTED], ok=/var/spool/shared All actions are therefore "normalized" into canonical names: bounce, reject => bounce confirm => confirm accept, deliver, ok => deliver drop, exit, stop => drop hold => hold Also, default delivery may be specified in addition to delivery to a specific location: ok, deliver=/var/spool/shared Default delivery will be represented with a value of None in the value tuple: ok, deliver=&[EMAIL PROTECTED], bounce=yousuck.txt This leads to a dictionary that looks like this: { 'deliver' : ( None, '&[EMAIL PROTECTED]' ), 'bounce' : ( 'yousuck.txt', ) } The next step is to make tmda-rfilter process multiple actions and then, finally, to make this whole thing work with DELIVERY. The function to parse the entire action string and return a dictionary is a module-level function in FilterParser.py, so a multi-action DELIVERY can already be parsed. It's just a matter of wiring it in. Here's a demo run from the interpreter: >>> source = 'DELIVERY' >>> s = "ok,deliver=&[EMAIL PROTECTED] , bounce=yousuck.txt" >>> d = make_action_dict(s, source) >>> d {'deliver': (None, '&[EMAIL PROTECTED]'), 'bounce': ('yousuck.txt',)} Here's an action missing an option... >>> s = "ok=, bounce" >>> d = make_action_dict(s, source) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 22, in make_action_dict Error: "DELIVERY": missing option after "ok" And finally, here's an action line with an incoming action and an outgoing action accidentally mixed on the same line: >>> source = 'from' >>> s = "ok, bare" >>> d = make_action_dict(s, source) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 11, in make_action_dict Error: "from": garbage after "ok" So... I'm off to finish hooking this in, hopefully by Sunday evening or before. Tim _________________________________________________ tmda-workers mailing list ([EMAIL PROTECTED]) http://tmda.net/lists/listinfo/tmda-workers
