Commit 3c989a7e authored by Nicolas Delaby's avatar Nicolas Delaby

EmailDocument is a TextDocument which does not implement

IBaseConvertable.
  * replace getTextFormat by getContentType
   


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35244 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5586b333
......@@ -112,7 +112,7 @@ class ProxiedMethod(Method):
return method(*args, **kw)
# generate all proxy method on EmailDocumentProxyMixin
for method_id in ('getTextFormat',
for method_id in ('getContentType',
'getContentInformation', 'getAttachmentData',
'getAttachmentInformationList'):
EmailDocumentProxyMixin.security.declareProtected(
......@@ -121,7 +121,7 @@ for method_id in ('getTextFormat',
setattr(EmailDocumentProxyMixin, method_id,
ProxiedMethod(method_id))
class EmailDocument(File, TextDocument):
class EmailDocument(TextDocument):
"""
EmailDocument is a File which stores its metadata in a form which
is similar to a TextDocument.
......@@ -169,6 +169,18 @@ class EmailDocument(File, TextDocument):
self._v_message = result
return result
def isSupportBaseDataConversion(self):
"""
"""
return False
security.declareProtected(Permissions.AccessContentsInformation, 'hasBaseData')
def hasBaseData(self):
"""
"""
return self.hasFile() or self.hasTextContent()
security.declareProtected(Permissions.AccessContentsInformation, 'getContentInformation')
def getContentInformation(self):
"""
......@@ -477,8 +489,8 @@ class EmailDocument(File, TextDocument):
return text_result
return text_result or default
security.declareProtected(Permissions.AccessContentsInformation, 'getTextFormat')
def getTextFormat(self, default=_MARKER):
security.declareProtected(Permissions.AccessContentsInformation, 'getContentType')
def getContentType(self, default=_MARKER):
"""
Returns the format of the email (text or html).
......@@ -487,9 +499,9 @@ class EmailDocument(File, TextDocument):
if not self.hasFile():
# Return the standard text format if no file was provided
if default is _MARKER:
return self._baseGetTextFormat()
return TextDocument.getContentType(self)
else:
return self._baseGetTextFormat(default)
return TextDocument.getContentType(self, default)
is_alternative = False
for part in self._getMessage().walk():
if part.is_multipart():
......@@ -546,11 +558,11 @@ class EmailDocument(File, TextDocument):
This is used in order to respond to a mail,
this put a '> ' before each line of the body
"""
if self.getTextFormat() == 'text/plain':
if self.getContentType() == 'text/plain':
body = self.asText()
if body:
return '> ' + str(body).replace('\n', '\n> ')
elif self.getTextFormat() == 'text/html':
elif self.getContentType() == 'text/html':
return '<br/><blockquote type="cite">\n%s\n</blockquote>' %\
self.asStrippedHTML()
return ''
......@@ -690,8 +702,6 @@ class EmailDocument(File, TextDocument):
# is not (yet) part of Document API
if getattr(attachment, 'getContentType', None) is not None:
mime_type = attachment.getContentType()
elif getattr(attachment, 'getTextFormat', None) is not None:
mime_type = attachment.getTextFormat()
else:
raise ValueError, "Cannot find mimetype of the document."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment