[Twisted-Python] SMTP server

Jean-Paul Calderone exarkun at divmod.com
Fri Nov 10 08:29:11 EST 2006


On Fri, 10 Nov 2006 10:57:31 +0100, Jan Bakuwel <jan.bakuwel at int.greenpeace.org> wrote:
>Hi Jean-Paul,
>> The situation is not ideal, but I think if you use
>> IMessageDeliveryFactory
>> instead of IMessageDelivery you'll be able to accomplish your goal.
>>
>> With IMessageDeliveryFactory, you can create a new IMessageDelivery
>> provider
>> for each SMTP transaction.  validateTo is still called multiple times on
>> your IMessageDelivery provider, but because a new one is created for each
>> transaction, you should be able to avoid making multiple deliveries to
>> your
>> real backend.
>>
>> (As I wrote that I realized it was not a very clear explanation at
>> all, but
>> I cannot think of another way to put it without actually implementing
>> something).
>Are you suggesting that I would implement my own version of
>IMessageDelivery to include the abstract method I'm wishing for? Just
>trying to understand what you're suggesting... :-)

You should implement IMessageDelivery and your implementation should keep
internal state which tracks which users the message should be delivered to.
This state should be transferred to the IMessage provider which validateTo
returns.  When IMessage.messageDone is called, you should use that state to
deliver the message once and only once to the intended recipients.

IMessage.messageDone is the notification you want, as long as you are using
a different IMessageDelivery for each message, which is what implementing
IMessageDeliveryFactory lets you do.

Jean-Paul




More information about the Twisted-Python mailing list