Exemplo n.º 1
0
    def open_mailbox(self, session, mailbox_id):
        try:
            mbx_id = mailbox_id.lower()
            mfn = self.sys.mailbox[mbx_id]
            pfn = 'pickled-mailbox.%s' % mbx_id
        except KeyError:
            raise NoSuchMailboxError(_('No such mailbox: %s') % mbx_id)

        try:
            if mbx_id in self._mbox_cache:
                self._mbox_cache[mbx_id].update_toc()
            else:
                if session:
                    session.ui.mark(_('%s: Updating: %s') % (mbx_id, mfn))
                self._mbox_cache[mbx_id] = self.load_pickle(pfn)
        except:
            if self.sys.debug:
                import traceback
                traceback.print_exc()
            if session:
                session.ui.mark(
                    _('%s: Opening: %s (may take a while)') % (mbx_id, mfn))
            editable = self.is_editable_mailbox(mbx_id)
            mbox = OpenMailbox(mfn, create=editable)
            mbox.editable = editable
            mbox.save(session,
                      to=pfn,
                      pickler=lambda o, f: self.save_pickle(o, f))
            self._mbox_cache[mbx_id] = mbox

        # Always set this, it can't be pickled
        self._mbox_cache[mbx_id]._encryption_key_func = \
            lambda: self.prefs.obfuscate_index

        return self._mbox_cache[mbx_id]
Exemplo n.º 2
0
    def open_mailbox(self, session, mailbox_id):
        try:
            mbx_id = mailbox_id.lower()
            mfn = self.sys.mailbox[mbx_id]
            pfn = 'pickled-mailbox.%s' % mbx_id
        except KeyError:
            raise NoSuchMailboxError(_('No such mailbox: %s') % mbx_id)

        try:
            if mbx_id in self._mbox_cache:
                self._mbox_cache[mbx_id].update_toc()
            else:
                if session:
                    session.ui.mark(_('%s: Updating: %s') % (mbx_id, mfn))
                self._mbox_cache[mbx_id] = self.load_pickle(pfn)
        except:
            if self.sys.debug:
                import traceback
                traceback.print_exc()
            if session:
                session.ui.mark(_('%s: Opening: %s (may take a while)'
                                  ) % (mbx_id, mfn))
            editable = self.is_editable_mailbox(mbx_id)
            mbox = OpenMailbox(mfn, self, create=editable)
            mbox.editable = editable
            mbox.save(session,
                      to=pfn,
                      pickler=lambda o, f: self.save_pickle(o, f))
            self._mbox_cache[mbx_id] = mbox

        # Always set this, it can't be pickled
        self._mbox_cache[mbx_id]._encryption_key_func = \
            lambda: self.prefs.obfuscate_index

        return self._mbox_cache[mbx_id]
Exemplo n.º 3
0
    def open_mailbox(self, session, mailbox_id):
        try:
            mbx_id = mailbox_id.lower()
            mfn = self.sys.mailbox[mbx_id]
            pfn = "pickled-mailbox.%s" % mbx_id
        except KeyError:
            raise NoSuchMailboxError(_("No such mailbox: %s") % mbx_id)

        try:
            if mbx_id in self._mbox_cache:
                self._mbox_cache[mbx_id].update_toc()
            else:
                if session:
                    session.ui.mark(_("%s: Updating: %s") % (mbx_id, mfn))
                self._mbox_cache[mbx_id] = self.load_pickle(pfn)
        except:
            if self.sys.debug:
                import traceback

                traceback.print_exc()
            if session:
                session.ui.mark(_("%s: Opening: %s (may take a while)") % (mbx_id, mfn))
            editable = self.is_editable_mailbox(mbx_id)
            mbox = OpenMailbox(mfn, create=editable)
            mbox.editable = editable
            mbox.save(session, to=pfn, pickler=lambda o, f: self.save_pickle(o, f))
            self._mbox_cache[mbx_id] = mbox

        return self._mbox_cache[mbx_id]