pluging maildir: some trivial fixes:
- path is now (local dir)/maildir/(profile name) instead of directly (profile name)
- removed forgotten breakpoint
- use of MaildirError instead of the inexistant MailboxException
- fixed some forgotten "self."
This commit is contained in:
parent
7f86a9adf7
commit
52abf00bb4
1 changed files with 8 additions and 10 deletions
|
|
@ -30,7 +30,6 @@ from email.charset import Charset
|
|||
import os
|
||||
from cStringIO import StringIO
|
||||
from twisted.internet import reactor
|
||||
import pdb
|
||||
from sat.core.exceptions import ProfileUnknownError
|
||||
from sat.memory.persistent import PersistentBinaryDict
|
||||
|
||||
|
|
@ -128,7 +127,7 @@ class MaildirBox(object):
|
|||
error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
assert self.__mailboxes[profile][boxname] == mailboxUser
|
||||
del __mailboxes[profile][boxname]
|
||||
del self.__mailboxes[profile][boxname]
|
||||
|
||||
def _checkBoxReference(self, boxname, profile):
|
||||
"""Check if there is a reference on a box, and return it
|
||||
|
|
@ -211,7 +210,7 @@ class MaildirBox(object):
|
|||
@return: list of strings"""
|
||||
box_data = self.__getBoxData(boxname, profile)
|
||||
if mess_id not in box_data:
|
||||
raise MailboxException("Trying to get flags from an unexisting message")
|
||||
raise MaildirError("Trying to get flags from an unexisting message")
|
||||
return box_data[mess_id][1]
|
||||
|
||||
def setFlags(self, boxname, mess_id, flags, profile):
|
||||
|
|
@ -224,7 +223,7 @@ class MaildirBox(object):
|
|||
assert(type(flags) == list)
|
||||
flags = [flag.upper() for flag in flags] # we store every flag UPPERCASE
|
||||
if mess_id not in box_data:
|
||||
raise MailboxException("Trying to set flags for an unexisting message")
|
||||
raise MaildirError("Trying to set flags for an unexisting message")
|
||||
box_data[mess_id][1] = flags
|
||||
self.data[profile].force(boxname)
|
||||
|
||||
|
|
@ -334,14 +333,14 @@ class MailboxUser(object):
|
|||
THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead"""
|
||||
if _maildir._checkBoxReference(name, profile):
|
||||
error("INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
|
||||
raise MailboxException('double MailboxUser instanciation')
|
||||
raise MaildirError('double MailboxUser instanciation')
|
||||
if name != "INBOX":
|
||||
raise NotImplementedError
|
||||
self.name = name
|
||||
self.profile = profile
|
||||
self.maildir = _maildir
|
||||
profile_path = self.maildir._getProfilePath(profile)
|
||||
full_profile_path = os.path.join(self.maildir.host.memory.getConfig('', 'local_dir'), profile_path)
|
||||
full_profile_path = os.path.join(self.maildir.host.memory.getConfig('', 'local_dir'), 'maildir', profile_path)
|
||||
if not os.path.exists(full_profile_path):
|
||||
os.makedirs(full_profile_path, 0700)
|
||||
mailbox_path = os.path.join(full_profile_path, MAILDIR_PATH)
|
||||
|
|
@ -363,9 +362,9 @@ class MailboxUser(object):
|
|||
self.maildir.cleanTable(self.name, existant_id, profile=self.profile)
|
||||
|
||||
def __del__(self):
|
||||
if observer:
|
||||
if self.observer:
|
||||
debug("removing observer for %s" % self.name)
|
||||
self._maildir.removeObserver(observer, self.name, "NEW_MESSAGE")
|
||||
self._maildir.removeObserver(self.observer, self.name, "NEW_MESSAGE")
|
||||
self.maildir._removeBoxAccess(self.name, self, profile=self.profile)
|
||||
|
||||
def addMessage(self, message):
|
||||
|
|
@ -483,5 +482,4 @@ class MailboxUser(object):
|
|||
|
||||
def emptyTrash(self):
|
||||
"""Delete everything in the .Trash dir"""
|
||||
import shutils
|
||||
pdb.set_trace()
|
||||
pass #TODO
|
||||
|
|
|
|||
Loading…
Reference in a new issue