changeset 622:9a8fbf0e8691

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."
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2013 12:37:06 +0200
parents 0e16288d6816
children 47d3a22b4629
files src/plugins/plugin_misc_maildir.py
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_maildir.py	Thu Jun 20 12:14:43 2013 +0200
+++ b/src/plugins/plugin_misc_maildir.py	Thu Jun 20 12:37:06 2013 +0200
@@ -30,7 +30,6 @@
 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 @@
             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 @@
         @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 @@
         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 @@
            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 @@
         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 @@
 
     def emptyTrash(self):
         """Delete everything in the .Trash dir"""
-        import shutils
-        pdb.set_trace()
+        pass #TODO