[Twisted-Python] imap and noop

Darren Syzling dsyzling at gmail.com
Wed Jul 8 11:32:37 EDT 2009

Jean-Paul Calderone wrote:
> You may want to use the IMailboxListener implementation on IMAP4Server to
> handle this case (IMAP4's complicated, I'm not sure this is the right
> direction to pursue, but it's *a* direction :).
I'm glad you said that I thought I was going mad, I'm mired in stateful 
conversations between client and server. This started out as a simple 
internal test tool. I spiked it and thought ok that's simple I can 
read/view messages, the code looked straight forward. Store some state 
for each mailbox pickle to a file for simplicity. But then I got deeper 
into the whole delete to trash (which is in fact copy) and that's when 
it all went horribly wrong. Thunderbird can start multiple sessions 
which creates multiple mailbox instances server side and that throws the 
whole state management issue up in the air. So I went stateless and 
re-read the pickle file on each mailbox entry point - ugly but it 
improved consistency and made the whole thing easier to reason.  But the 
noop has thrown me because this may expect me to respond to the 
individual session (mailbox instance) - something you're alluding to 
below about tracking the IMAP4Server protocol.
> The modeChanged, flagsChanged, and newMessages methods on IMAP4Server are
> intended for use by your mailbox implementation.  In this case, it sounds
> like you want to have your trash mailbox call newMessages when the messages
> are copied into it.  This requires a bit of legwork on your part, keeping
> track of the IMAP4Server protocol (or possibly more than one!) from the
> mailbox code, but the result should be that when Thunderbird sends those
> NOOPs, the server responds with one or both of EXISTS or RECENT (untagged).
Thanks I'll have a poke around and see how this looks. I really ought to 
cap my time on this, it was only an internal test helper. I may end up 
telling my test users - 'ah yeah well, just close Thunderbird, restart 
and sign in and those messages will magically appear.' Although knowing 
me it will niggle at me until I've solved it.


More information about the Twisted-Python mailing list