[Twisted-Python] IMAP4 Proxy to add headers and modify body of an incoming message

Hello, I am trying to write an IMAP proxy to modify headers and the body of an incoming message using twisted. I am new to python and twisted so maybe this is why I either picked the wrong route or don't have the skills to get through some issues and I'm hoping that some you fine list members can point me in the right direction.
I started by using the IMAP4Client and IMAP4Server to do the proxying. However, I realized that in certain cases, the IMAP4Server requires synchronous results but since I need to do an async call using the client the handling is not working properly. I ran into this when implementing getFlags() in the IMessage and I am not sure how I can get out of this short of changing the IMAP4Server code to handle Deferreds.
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?

Maybe I asked the wrong question? Is it possible to use the imap4 library from twisted to write an imap4 proxy?
________________________________ From: Krzysztof Oblucki koblucki@yahoo.com To: "twisted-python@twistedmatrix.com" twisted-python@twistedmatrix.com Sent: Monday, November 25, 2013 11:27 AM Subject: IMAP4 Proxy to add headers and modify body of an incoming message
Hello, I am trying to write an IMAP proxy to modify headers and the body of an incoming message using twisted. I am new to python and twisted so maybe this is why I either picked the wrong route or don't have the skills to get through some issues and I'm hoping that some you fine list members can point me in the right direction.
I started by using the IMAP4Client and IMAP4Server to do the proxying. However, I realized that in certain cases, the IMAP4Server requires synchronous results but since I need to do an async call using the client the handling is not working properly. I ran into this when implementing getFlags() in the IMessage and I am not sure how I can get out of this short of changing the IMAP4Server code to handle Deferreds.
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?

From: Krzysztof Oblucki koblucki@yahoo.com To: "twisted-python@twistedmatrix.com" <twisted- python@twistedmatrix.com> Sent: Monday, November 25, 2013 11:27 AM Subject: IMAP4 Proxy to add headers and modify body of an incoming message
Hello, I am trying to write an IMAP proxy to modify headers and the body of an incoming message using twisted. I am new to python and twisted so maybe this is why I either picked the wrong route or don't have the skills to get through some issues and I'm hoping that some you fine list members can point me in the right direction.
I started by using the IMAP4Client and IMAP4Server to do the proxying. However, I realized that in certain cases, the IMAP4Server requires synchronous results but since I need to do an async call using the client the handling is not working properly. I ran into this when implementing getFlags() in the IMessage and I am not sure how I can get out of this short of changing the IMAP4Server code to handle Deferreds.
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently.
Jean-Paul

Awesome, that's what I've been trying to do for the past couple of days. Definitely learning a lot of new things :)
________________________________ From: "exarkun@twistedmatrix.com" exarkun@twistedmatrix.com To: Twisted general discussion twisted-python@twistedmatrix.com Sent: Wednesday, November 27, 2013 5:18 PM Subject: Re: [Twisted-Python] IMAP4 Proxy to add headers and modify body of an incoming message
From: Krzysztof Oblucki koblucki@yahoo.com To: "twisted-python@twistedmatrix.com" <twisted- python@twistedmatrix.com> Sent: Monday, November 25, 2013 11:27 AM Subject: IMAP4 Proxy to add headers and modify body of an incoming message
Hello, I am trying to write an IMAP proxy to modify headers and the body of an incoming message using twisted. I am new to python and twisted so maybe this is why I either picked the wrong route or don't have the skills to get through some issues and I'm hoping that some you fine list members can point me in the right direction.
I started by using the IMAP4Client and IMAP4Server to do the proxying. However, I realized that in certain cases, the IMAP4Server requires synchronous results but since I need to do an async call using the client the handling is not working properly. I ran into this when implementing getFlags() in the IMessage and I am not sure how I can get out of this short of changing the IMAP4Server code to handle Deferreds.
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently.
Jean-Paul
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On Nov 27, 2013, at 6:39 PM, Krzysztof Oblucki koblucki@yahoo.com wrote:
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently.
Awesome, that's what I've been trying to do for the past couple of days. Definitely learning a lot of new things :)
Perhaps you should file a ticket for this? (Searching for one first, of course, to see if it already exists).
Thanks,
-glyph

I will do that. I'm struggling with doing this myself so far because of my noobness but making small progress every day.
Sent from my BatPhone
On Nov 27, 2013, at 23:34, Glyph glyph@twistedmatrix.com wrote:
On Nov 27, 2013, at 6:39 PM, Krzysztof Oblucki koblucki@yahoo.com wrote:
Am I on the right track? Is imap4 lib the right tool for this job? If so, is modifying IMAP4Server to handle Deferreds the right thing to do? If not, what would you recommend?
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently.
Awesome, that's what I've been trying to do for the past couple of days. Definitely learning a lot of new things :)
Perhaps you should file a ticket for this? (Searching for one first, of course, to see if it already exists).
Thanks,
-glyph

On Nov 28, 2013, at 12:10 PM, Krzysztof Oblucki koblucki@yahoo.com wrote:
I will do that. I'm struggling with doing this myself so far because of my noobness but making small progress every day.
Feel free to ask here for any help you might need :).
-glyph

It would be great if I could get some pointers as to the correct way of doing it. If I were to start with search_DELETED what would be your recommendation?
Sent from my BatPhone
On Nov 28, 2013, at 20:07, Glyph glyph@twistedmatrix.com wrote:
On Nov 28, 2013, at 12:10 PM, Krzysztof Oblucki koblucki@yahoo.com wrote:
I will do that. I'm struggling with doing this myself so far because of my noobness but making small progress every day.
Feel free to ask here for any help you might need :).
-glyph
participants (3)
-
exarkun@twistedmatrix.com
-
Glyph
-
Krzysztof Oblucki