
On Mon, Jun 10, 2013 at 2:09 PM, Hrvoje Niksic <hniksic@xemacs.org> wrote:
If my understanding is correct, you want exim configuration to define which Python functions will be called by exim, without an API defined upfront.
Thank you for phrasing it properly, I was doing such a poor job. That is exactly what I am doing.
I had to do a little work to figure out how many arguments the function is written to accept, and then double check that the call from the exim ACL's is using the correct number, and only then convert the variables and make the function call. Why would you need to do that -- can't you just call the function and leave it to raise an exception if called with an incorrect argument count?
Because it segfaulted instead of raising an exception. If you remove lines 151-158 in python.c (http://git.exim.org/users/tlyons/exim.git/blob/4469a42e017cb6e44646d453b86e4...), then it will segfault when the function is called with the incorrect number of args.
This will work and is easy to implement, but it does feel a bit more Perlish than Pythonic. If you want to go for a solution with a more native Python accent, I'd recommend passing the Python function some sort of context argument. Instead of a string, this would be an object with some methods that retrieve the message information, such as headers, and others to affect the response. This needn't be a complex framework -- if designed carefully, excellent functionality can be achieved with a very small number of methods.
Noted, thanks for the input. That's good stuff.
...Todd
The total budget at all receivers for solving senders' problems is $0. If you want them to accept your mail and manage it the way you want, send it the way the spec says to. --John Levine