[PATCH 04/13] Update to match semantics of new imaplib2
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Feb 7 12:12:47 GMT 2011
On Sun, 6 Feb 2011 11:58:58 -0500, Ethan Glasser-Camp <ethan at betacantrips.com> wrote:
> The biggest change here is that imapobj.untagged_responses is no
> longer a dictionary, but a list. To access it, I use the semi-private
> _get_untagged_response method.
> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
> index db1bdae..2c6ced7 100644
...
> @@ -85,14 +85,14 @@ class IMAPFolder(BaseFolder):
> imapobj = self.imapserver.acquireconnection()
> try:
> # Primes untagged_responses
> - imapobj.select(self.getfullname(), readonly = 1, force = 1)
> + imaptype, imapdata = imapobj.select(self.getfullname(), readonly = 1, force = 1)
> try:
> # 1. Some mail servers do not return an EXISTS response
> # if the folder is empty. 2. ZIMBRA servers can return
> # multiple EXISTS replies in the form 500, 1000, 1500,
> # 1623 so check for potentially multiple replies.
> maxmsgid = 0
> - for msgid in imapobj.untagged_responses['EXISTS']:
> + for msgid in imapdata:
> maxmsgid = max(long(msgid), maxmsgid)
> except KeyError:
> return True
Careful here, are we really sure that we are doing the right thing here
(and analogue in the quickchanged function)? There are 3 possible return
scenarioes here (ignoring the "BAD" reply for a moment which we should
have protected against anyway):
1) Return exactly one "EXISTS" reply. Everything is fine.
2) Don't return any EXISTS when the folder is empty (as some servers are
doing per comment). Previously the KeyError exception would have
handled that. Now, we can never trigger the KeyError case, so that
one has become useless. (but it seems we would set maxmsgid to 0, so
we should be fine with regard to what we return. Do away with the
KeyError exception here?
3) Return multiple EXISTS messages, will the imaplib2 code return all of
them or only one? imaplib2 does:
typ, dat = self._untagged_response(typ, [None], 'EXISTS')
in select(). Will that return a list of multiple EXISTS values if we
get them? Perhaps it is, but I am not sure.
Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20110207/4bb0f602/attachment-0001.sig>
More information about the OfflineIMAP-project
mailing list