--- imaplib.py-old 2007-07-07 09:33:57.000000000 +0200 +++ imaplib.py 2007-07-07 08:37:18.000000000 +0200 @@ -615,9 +615,23 @@ Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via .response('FLAGS') etc. """ + # + # From rfc2060: + # If the client is not permitted to modify the mailbox but is permitted + # read access, the mailbox is selected as read-only, and the server MUST + # prefix the text of the tagged OK response to SELECT with the + # "[READ-ONLY]" response code. Read-only access through SELECT differs + # from the EXAMINE command in that certain read-only mailboxes MAY + # permit the change of permanent state on a per-user (as opposed to + # global) basis. Netnews messages marked in a server-based .newsrc file + # are an example of such per-user permanent state that can be modified + # with read-only mailboxes. + # + # The 'readonly' parameter should be renamed to 'examine', to avoid + # confusion. + # self.untagged_responses = {} # Flush old responses. - self.is_readonly = readonly - if readonly is not None: + if readonly: name = 'EXAMINE' else: name = 'SELECT' @@ -626,12 +640,13 @@ self.state = 'AUTH' # Might have been 'SELECTED' return typ, dat self.state = 'SELECTED' - if 'READ-ONLY' in self.untagged_responses \ - and not readonly: + self.is_readonly = 'READ-ONLY' in self.untagged_responses + if self.is_readonly and not readonly \ + and not 's' in self.myrights( mailbox)[1][0].split(' ')[-1]: if __debug__: if self.debug >= 1: self._dump_ur(self.untagged_responses) - raise self.readonly('%s is not writable' % mailbox) + raise self.readonly('%s does not even allow per-user state saving' % mailbox) return typ, self.untagged_responses.get('EXISTS', [None]) @@ -791,6 +806,8 @@ if typ in self.untagged_responses: del self.untagged_responses[typ] + # This piece of code is meant to detect changes from READ-WRITE to + # READ-ONLY. Its purpose is thereofore unaffected by the changes above if 'READ-ONLY' in self.untagged_responses \ and not self.is_readonly: raise self.readonly('mailbox status changed to READ-ONLY')