ZODB Components: Migrate Products.ERP5.Tool.NotificationTool from filesystem.
Showing
... | @@ -27,25 +27,19 @@ | ... | @@ -27,25 +27,19 @@ |
# | # | ||
############################################################################## | ############################################################################## | ||
import re, types | import re | ||
from email.utils import formataddr | |||
from DateTime import DateTime | from DateTime import DateTime | ||
from AccessControl import ClassSecurityInfo, Unauthorized | from AccessControl import ClassSecurityInfo | ||
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter | from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter | ||
from Products.CMFCore.utils import _checkPermission | |||
from Products.ERP5Type import Permissions, PropertySheet | from Products.ERP5Type import Permissions, PropertySheet | ||
from Products.ERP5.Document.TextDocument import TextDocument | from Products.ERP5.Document.TextDocument import TextDocument | ||
from Products.ERP5.Document.File import File | from Products.ERP5.Document.File import File | ||
from Products.ERP5.Document.Document import ConversionError | |||
from Products.ERP5.mixin.mail_message import MailMessageMixin, testCharsetAndConvert | from Products.ERP5.mixin.mail_message import MailMessageMixin, testCharsetAndConvert | ||
from Products.ERP5.mixin.document_proxy import DocumentProxyMixin, DocumentProxyError | from Products.ERP5.mixin.document_proxy import DocumentProxyMixin, DocumentProxyError | ||
from Products.ERP5.Tool.NotificationTool import buildEmailMessage | |||
from Products.ERP5Type.Utils import guessEncodingFromText | |||
from MethodObject import Method | from MethodObject import Method | ||
from zLOG import LOG, INFO | |||
try: | try: | ||
from Products.MimetypesRegistry.common import MimeTypeException | from Products.MimetypesRegistry.common import MimeTypeException # pylint: disable=unused-import | ||
except ImportError: | except ImportError: | ||
class MimeTypeException(Exception): | class MimeTypeException(Exception): | ||
""" | """ | ||
... | @@ -54,12 +48,11 @@ except ImportError: | ... | @@ -54,12 +48,11 @@ except ImportError: |
""" | """ | ||
from email import message_from_string | from email import message_from_string | ||
from email.header import decode_header, HeaderParseError | |||
from email.utils import parsedate_tz, mktime_tz | from email.utils import parsedate_tz, mktime_tz | ||
DEFAULT_TEXT_FORMAT = 'text/html' | DEFAULT_TEXT_FORMAT = 'text/html' | ||
COMMASPACE = ', ' | COMMASPACE = ', ' | ||
_MARKER = [] | _MARKER = () | ||
|
|||
filename_regexp = 'name="([^"]*)"' | filename_regexp = 'name="([^"]*)"' | ||
... | @@ -255,11 +248,11 @@ class EmailDocument(TextDocument, MailMessageMixin): | ... | @@ -255,11 +248,11 @@ class EmailDocument(TextDocument, MailMessageMixin): |
else: | else: | ||
part_encoding = part.get_content_charset() | part_encoding = part.get_content_charset() | ||
message_text = part.get_payload(decode=1) | message_text = part.get_payload(decode=1) | ||
text_result, encoding = testCharsetAndConvert(message_text, | text_result, _ = testCharsetAndConvert(message_text, | ||
part.get_content_type(), | part.get_content_type(), | ||
part_encoding) | part_encoding) | ||
if part.get_content_type() == 'text/html': | if part.get_content_type() == 'text/html': | ||
mime, text_result = self.convert(format='html', | _, text_result = self.convert(format='html', | ||
text_content=text_result, | text_content=text_result, | ||
charset=part_encoding) | charset=part_encoding) | ||
... | @@ -287,7 +280,7 @@ class EmailDocument(TextDocument, MailMessageMixin): | ... | @@ -287,7 +280,7 @@ class EmailDocument(TextDocument, MailMessageMixin): |
else: | else: | ||
return part.get_content_type() | return part.get_content_type() | ||
email_parser = re.compile('[ ;,<>\'"]*([^<> ;,\'"]+?\@[^<> ;,\'"]+)[ ;,<>\'"]*', re.IGNORECASE) | email_parser = re.compile(r'[ ;,<>\'"]*([^<> ;,\'"]+?\@[^<> ;,\'"]+)[ ;,<>\'"]*', re.IGNORECASE) | ||
security.declareProtected(Permissions.AccessContentsInformation, 'getContentURLList') | security.declareProtected(Permissions.AccessContentsInformation, 'getContentURLList') | ||
def getContentURLList(self): | def getContentURLList(self): | ||
""" | """ | ||
... | ... |