From: Kerry K. <kk...@gm...> - 2012-01-31 02:25:24
|
On Mon, Jan 30, 2012 at 5:37 PM, Ross Boylan <ro...@bi...> wrote: > I think that it is not possible to reconstruct exactly which messages > were added and removed in some circumstances. Is my understanding > correct? > > That is my understanding as well. > If this sequence came back from the server > * 4 EXPUNGE > * 5 EXISTS > then the new message is sequence 5. > > Assuming you're in an IDLE, yes. If you got that in response to a UID FETCH, for example, then it'd mean that 5 messages exist... but not necessarily that message 5 is new. > If this sequence came back > * 5 EXISTS > * 4 EXPUNGE > then the new message is sequence 4. > > Correct (again assuming you're in an IDLE). The sequence numbers above the expunged message decrement immediately. RFC 3501, 7.4.1. > Since imaplib2 only gives the relative time sequence within a single > class of untagged response (i.e., EXPUNGE or EXISTS) there is no way to > tell which of these scenarios happened assuming one recovers the 2 > separate responses. > > So far as I can tell this is also correct. And for what it's worth the original imaplib behaves the same. > For my purposes that level of detail is probably not necessary; I can > just err on the side of caution. > > Perhaps imaplib2 should have a callback that would enable tracking the > exact sequence of messages. > You can monkeypatch imaplib2 to keep track of the exact sequence of untagged responses. Here's the patch that I applied to imaplib... You should be able to adapt it for imaplib2: def patch(): imaplib.IMAP4._append_untagged = _append_untagged def _append_untagged(self, typ, dat): ## # The original code if dat is None: dat = '' ur = self.untagged_responses if __debug__: if self.debug >= 5: self._mesg('untagged_responses[%s] %s += ["%s"]' % (typ, len(ur.get(typ,'')), dat)) if typ in ur: ur[typ].append(dat) else: ur[typ] = [dat] # ## ## # The new code try: self.ordered_untagged_responses.append((typ, dat)) except AttributeError: self.ordered_untagged_responses = list((typ, dat)) # ## With all of that said, Piers might be aware of something that we're not... Cheers, -K > > Ross Boylan > > > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > Imaplib2-devel mailing list > Ima...@li... > https://lists.sourceforge.net/lists/listinfo/imaplib2-devel > |