fix behaviour for delete/expunge, when lacking rights

This patch maneuvers around python imaplib's mysterious read-only detection
algorithm and correctly calls the UI's deletetoreadonly(), when trying to
delete/expunge in a mailbox without having the necessary rights.
This commit is contained in:
Florian Friesdorf 2007-07-12 04:44:11 +01:00
parent 2efc4589a0
commit c305d63e00

View File

@ -424,12 +424,17 @@ class IMAPFolder(BaseFolder):
self.addmessagesflags_noconvert(uidlist, ['T']) self.addmessagesflags_noconvert(uidlist, ['T'])
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
try: try:
try: # Making sure, that we have the necessary rights
imapobj.select(self.getfullname()) # ensuring that we access readonly: python's braindead imaplib.py
except imapobj.readonly: # otherwise might raise an exception during the myrights() call
imapobj.select(self.getfullname(),readonly=1)
if not 'd' in imapobj.myrights(self.getfullname())[1][0].split()[1]:
# no delete/expunge rights
UIBase.getglobalui().deletereadonly(self, uidlist) UIBase.getglobalui().deletereadonly(self, uidlist)
return return
if self.expunge: if self.expunge:
imapobj.select(self.getfullname())
assert(imapobj.expunge()[0] == 'OK') assert(imapobj.expunge()[0] == 'OK')
finally: finally:
self.imapserver.releaseconnection(imapobj) self.imapserver.releaseconnection(imapobj)