]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Support for modifiers in the FETCH command (#62)
authorMenno Smits <menno@freshfoo.com>
Thu, 27 Jan 2011 13:55:11 +0000 (13:55 +0000)
committerMenno Smits <menno@freshfoo.com>
Thu, 27 Jan 2011 13:55:11 +0000 (13:55 +0000)
NEWS
THANKS
imapclient/imapclient.py
livetest.py

diff --git a/NEWS b/NEWS
index 86542d56ceed0749c7cd50fc4de28670afe8b49f..5fdd2953704fb8c918ae25714201950f93728a73 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+.. -*-Mode: rst; -*-
+
 =====
  Dev
 =====
@@ -50,10 +52,16 @@ IMAP account parameters are now read using a configuration file
 instead of command line arguments. See livetest-sample.ini for an
 example.
 
-Added NAMESPACE support (#63)
------------------------------
+Added NAMESPACE support (#63) [API CHANGE]
+------------------------------------------
 namespace() method added and get_folder_delimiter() has been deprecated.
 
+Added support for FETCH modifiers (#62) [NEW]
+---------------------------------------------
+The fetch method now takes optional modifiers as the last
+argument. These are required for extensions such as RFC 4551
+(conditional store). Thanks to Thomas Jost for the patch.
+
 ===============
  Version 0.6.2
 ===============
diff --git a/THANKS b/THANKS
index b592aba16541f4a598b2c2c18235ff2454d07723..da6b228f9a3e5945b1c6c391335da44530a016e4 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -17,8 +17,11 @@ Michael Foord
     IMAPClient is distributed with Michael's excellent mock.py 
     (http://www.voidspace.org.uk/python/mock/)
 
-Mark Hammond <mhammond _AT_ skipinet.com.au)
-     Much work related to response parsing.
+Mark Hammond (mhammond _AT_ skipinet.com.au)
+    Much work related to response parsing and many bug reports.
+
+Thomas Jost (schnouki _AT_ schnouki.net)
+    FETCH modifiers patch.
 
 
 Bug Reports
index 36cf46fce372eb81c19d9f4ae5cde787e7ed4795..24b424c17bbb101bc77660e344e15d3aaeb42de9 100644 (file)
@@ -489,7 +489,8 @@ class IMAPClient(object):
 
         @param messages: Message IDs to fetch.
         @param parts: A sequence of data items to retrieve.
-        @param modifiers: An optional sequence of modifiers.
+        @param modifiers: An optional sequence of modifiers (where
+            supported by the server, eg. ['CHANGEDSINCE 123']).
         @return: A dictionary indexed by message number. Each item is itself a
             dictionary containing the requested message parts.
             INTERNALDATE parts will be returned as datetime objects converted
index 17dec5951830481daf3a5e8449c33ddb3a38ce7b..fdd4bb11eb222e40aef1f61bc7940f8ab906aa24 100755 (executable)
@@ -387,6 +387,26 @@ def createLiveTestClass(host, username, password, port, ssl, use_uid, namespace)
             self.assertEqual(len(body), 25)
             self.assertTrue(body.startswith('om: Bob Smith'))
 
+
+        def test_fetch_modifiers(self):
+            # CONDSTORE (RFC 4551) provides a good way to use FETCH
+            # modifiers but it isn't commonly available.
+            if not self.client.has_capability('CONDSTORE'):
+                return self.skipTest("Server doesn't support CONDSTORE")
+
+            maxModSeq = int(self.client.select_folder('INBOX')['HIGHESTMODSEQ'][0])
+            self.client.append('INBOX', SIMPLE_MESSAGE)
+            msg_id = self.client.search()[0]
+
+            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % maxModSeq])
+            msg_info = resp[msg_id]
+            self.assertIn('MODSEQ', msg_info)
+
+            # Prove that the modifier is actually being used
+            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % (maxModSeq + 1)])
+            self.assertFalse(resp)
+            
+
         def test_BODYSTRUCTURE(self):
             self.client.select_folder('INBOX')
             self.client.append('INBOX', SIMPLE_MESSAGE)