Merge pull request #265 from spametki/master

Fixed imap get_last_message to return positive integer (google code issue 1729)
This commit is contained in:
mdipierro
2013-10-19 15:33:46 -07:00
2 changed files with 10 additions and 5 deletions
+1
View File
@@ -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',
+9 -5
View File
@@ -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):
@@ -6221,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)))