Merge pull request #241 from spametki/master
IMAP fixed patch for google code issue 1707
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
'(requires internet access, experimental)': '(requires internet access, experimental)',
|
||||
'(something like "it-it")': '(algo como "it-it")',
|
||||
'@markmin\x01(file **gluon/contrib/plural_rules/%s.py** is not found)': '(file **gluon/contrib/plural_rules/%s.py** is not found)',
|
||||
'@markmin\x01An error occured, please [[reload %s]] the page': 'An error occured, please [[reload %s]] the page',
|
||||
'@markmin\x01Searching: **%s** %%{file}': 'Searching: **%s** files',
|
||||
'A new version of web2py is available': 'Hay una nueva versión de web2py disponible',
|
||||
'A new version of web2py is available: %s': 'Hay una nueva versión de web2py disponible: %s',
|
||||
@@ -31,6 +32,7 @@
|
||||
'appadmin': 'appadmin',
|
||||
'appadmin is disabled because insecure channel': 'admin deshabilitado, el canal no es seguro',
|
||||
'application "%s" uninstalled': 'aplicación "%s" desinstalada',
|
||||
'application %(appname)s installed with md5sum: %(digest)s': 'application %(appname)s installed with md5sum: %(digest)s',
|
||||
'application compiled': 'aplicación compilada',
|
||||
'application is compiled and cannot be designed': 'la aplicación está compilada y no puede ser modificada',
|
||||
'Application name:': 'Application name:',
|
||||
@@ -92,6 +94,7 @@
|
||||
'Create new application using the Wizard': 'Create new application using the Wizard',
|
||||
'create new application:': 'nombre de la nueva aplicación:',
|
||||
'Create new simple application': 'Cree una nueva aplicación',
|
||||
'Create/Upload': 'Create/Upload',
|
||||
'created by': 'creado por',
|
||||
'crontab': 'crontab',
|
||||
'Current request': 'Solicitud en curso',
|
||||
|
||||
20
gluon/dal.py
20
gluon/dal.py
@@ -6124,7 +6124,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
else:
|
||||
return (uid_list[0], uid_list[-1])
|
||||
|
||||
def convert_date(self, date, add=None):
|
||||
def convert_date(self, date, add=None, imf=False):
|
||||
if add is None:
|
||||
add = datetime.timedelta()
|
||||
""" Convert a date object to a string
|
||||
@@ -6138,7 +6138,10 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
if isinstance(date, basestring):
|
||||
# Prevent unexpected date response format
|
||||
try:
|
||||
dayname, datestring = date.split(",")
|
||||
if "," in date:
|
||||
dayname, datestring = date.split(",")
|
||||
else:
|
||||
dayname, datestring = None, date
|
||||
date_list = datestring.strip().split()
|
||||
year = int(date_list[2])
|
||||
month = months.index(date_list[1].upper())
|
||||
@@ -6150,8 +6153,10 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
LOGGER.error("Could not parse date text: %s. %s" %
|
||||
(date, e))
|
||||
return None
|
||||
elif isinstance(date, (datetime.datetime, datetime.date)):
|
||||
return (date + add).strftime("%d-%b-%Y")
|
||||
elif isinstance(date, (datetime.date, datetime.datetime)):
|
||||
if imf: date_format = "%a, %d %b %Y %H:%M:%S %z"
|
||||
else: date_format = "%d-%b-%Y"
|
||||
return (date + add).strftime(date_format)
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -6532,7 +6537,8 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
|
||||
mailbox = table.mailbox
|
||||
d = dict(((k.name, v) for k, v in fields))
|
||||
date_time = (d.get("created", datetime.datetime.now())).timetuple()
|
||||
date_time = d.get("created", datetime.datetime.now())
|
||||
struct_time = date_time.timetuple()
|
||||
if len(d) > 0:
|
||||
message = d.get("email", None)
|
||||
attachments = d.get("attachments", [])
|
||||
@@ -6547,6 +6553,8 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
message = Message()
|
||||
message["from"] = d.get("sender", "")
|
||||
message["subject"] = d.get("subject", "")
|
||||
message["date"] = self.convert_date(date_time, imf=True)
|
||||
|
||||
if mime:
|
||||
message.set_type(mime)
|
||||
if charset:
|
||||
@@ -6569,7 +6577,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
[add_payload(message, c) for c in content]
|
||||
[add_payload(message, a) for a in attachments]
|
||||
message = message.as_string()
|
||||
return (mailbox, flags, date_time, message)
|
||||
return (mailbox, flags, struct_time, message)
|
||||
else:
|
||||
raise NotImplementedError("IMAP empty insert is not implemented")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user