|
@ -24,6 +24,7 @@ import base64 |
|
|
import simplejson |
|
|
import simplejson |
|
|
from lxml import etree |
|
|
from lxml import etree |
|
|
from openerp import models, fields, api, exceptions |
|
|
from openerp import models, fields, api, exceptions |
|
|
|
|
|
from openerp.tools.safe_eval import safe_eval |
|
|
from openerp.tools.translate import _ |
|
|
from openerp.tools.translate import _ |
|
|
from openerp.tools.misc import UnquoteEvalContext |
|
|
from openerp.tools.misc import UnquoteEvalContext |
|
|
_logger = logging.getLogger(__name__) |
|
|
_logger = logging.getLogger(__name__) |
|
@ -69,7 +70,8 @@ class fetchmail_server(models.Model): |
|
|
|
|
|
|
|
|
connection = this.connect() |
|
|
connection = this.connect() |
|
|
for folder in this.folder_ids.filtered('active'): |
|
|
for folder in this.folder_ids.filtered('active'): |
|
|
this.handle_folder(connection, folder) |
|
|
|
|
|
|
|
|
this.with_context(safe_eval(folder.context or '{}'))\ |
|
|
|
|
|
.handle_folder(connection, folder) |
|
|
connection.close() |
|
|
connection.close() |
|
|
|
|
|
|
|
|
return super(fetchmail_server, self).fetch_mail( |
|
|
return super(fetchmail_server, self).fetch_mail( |
|
@ -218,6 +220,15 @@ class fetchmail_server(models.Model): |
|
|
connection = this.connect() |
|
|
connection = this.connect() |
|
|
connection.select() |
|
|
connection.select() |
|
|
for folder in this.folder_ids.filtered('active'): |
|
|
for folder in this.folder_ids.filtered('active'): |
|
|
|
|
|
try: |
|
|
|
|
|
folder_context = safe_eval(folder.context or '{}') |
|
|
|
|
|
except Exception, e: |
|
|
|
|
|
raise exceptions.ValidationError( |
|
|
|
|
|
_('Invalid context "%s": %s') % (folder.context, e)) |
|
|
|
|
|
if not isinstance(folder_context, dict): |
|
|
|
|
|
raise exceptions.ValidationError( |
|
|
|
|
|
_('Context "%s" is not a dictionary.') % |
|
|
|
|
|
folder.context) |
|
|
if connection.select(folder.path)[0] != 'OK': |
|
|
if connection.select(folder.path)[0] != 'OK': |
|
|
raise exceptions.ValidationError( |
|
|
raise exceptions.ValidationError( |
|
|
_('Mailbox %s not found!') % folder.path) |
|
|
_('Mailbox %s not found!') % folder.path) |
|
|