[Erp5-report] r35244 nicolas - /erp5/trunk/products/ERP5/Document/EmailDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 12 18:35:34 CEST 2010
Author: nicolas
Date: Wed May 12 18:35:28 2010
New Revision: 35244
URL: http://svn.erp5.org?rev=35244&view=rev
Log:
EmailDocument is a TextDocument which does not implement
IBaseConvertable.
* replace getTextFormat by getContentType
Modified:
erp5/trunk/products/ERP5/Document/EmailDocument.py
Modified: erp5/trunk/products/ERP5/Document/EmailDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/EmailDocument.py?rev=35244&r1=35243&r2=35244&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/EmailDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/EmailDocument.py [utf8] Wed May 12 18:35:28 2010
@@ -112,7 +112,7 @@
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 @@
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.
@@ -168,6 +168,18 @@
result = message_from_string(str(self.getData()))
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 @@
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 @@
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 @@
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 @@
# 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."
More information about the Erp5-report
mailing list