From 58e4cd91ccd92ac51fc74e26c8f3ec053d550ffc Mon Sep 17 00:00:00 2001 From: spametki Date: Sat, 19 Oct 2013 09:57:08 -0300 Subject: [PATCH 1/2] Fixed imap get_last_message to return positive integer --- applications/admin/languages/es.py | 1 + gluon/dal.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/applications/admin/languages/es.py b/applications/admin/languages/es.py index 76cdb47a..e5ca7602 100644 --- a/applications/admin/languages/es.py +++ b/applications/admin/languages/es.py @@ -249,6 +249,7 @@ 'new plugin installed': 'nuevo plugin instalado', 'New plugin installed: web2py.plugin.attachment.w2p': 'New plugin installed: web2py.plugin.attachment.w2p', 'New plugin installed: web2py.plugin.dialog.w2p': 'New plugin installed: web2py.plugin.dialog.w2p', +'New plugin installed: web2py.plugin.math2py.w2p': 'New plugin installed: web2py.plugin.math2py.w2p', 'New Record': 'Registro nuevo', 'new record inserted': 'nuevo registro insertado', 'New simple application': 'Nueva aplicación', diff --git a/gluon/dal.py b/gluon/dal.py index ecaff604..2a45c241 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -6115,16 +6115,20 @@ class IMAPAdapter(NoSQLAdapter): def get_last_message(self, tablename): last_message = None - # request mailbox list to the server - # if needed + # request mailbox list to the server if needed. if not isinstance(self.connection.mailbox_names, dict): self.get_mailboxes() try: - result = self.connection.select(self.connection.mailbox_names[tablename]) + result = self.connection.select( + self.connection.mailbox_names[tablename]) last_message = int(result[1][0]) + # Last message must be a positive integer + if last_message == 0: + last_message = 1 except (IndexError, ValueError, TypeError, KeyError): e = sys.exc_info()[1] - LOGGER.debug("Error retrieving the last mailbox sequence number. %s" % str(e)) + LOGGER.debug("Error retrieving the last mailbox" + + " sequence number. %s" % str(e)) return last_message def get_uid_bounds(self, tablename): From 4c1de287cd727cf105b3c9d68f854f7e8aa067b4 Mon Sep 17 00:00:00 2001 From: spametki Date: Sat, 19 Oct 2013 16:50:20 -0300 Subject: [PATCH 2/2] dal imap: strip native folder names (google code issue 1734) --- gluon/dal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/dal.py b/gluon/dal.py index 2a45c241..990cf99a 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -6225,7 +6225,7 @@ class IMAPAdapter(NoSQLAdapter): sub_items = [sub_item for sub_item in sub_items \ if len(sub_item.strip()) > 0] # mailbox = sub_items[len(sub_items) -1] - mailbox = sub_items[-1] + mailbox = sub_items[-1].strip() # remove unwanted characters and store original names # Don't allow leading non alphabetic characters mailbox_name = re.sub('^[_0-9]*', '', re.sub('[^_\w]','',re.sub('[/ ]','_',mailbox)))