[Erp5-report] r37046 ivan - in /erp5/trunk/products/ERP5: interfaces/ mixin/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jul 12 15:04:22 CEST 2010
Author: ivan
Date: Mon Jul 12 15:04:21 2010
New Revision: 37046
URL: http://svn.erp5.org?rev=37046&view=rev
Log:
Define legacy ITextConvertable interface and proper implementation with deprecation warning. Add method security definition and update doc strings.
Modified:
erp5/trunk/products/ERP5/interfaces/text_convertable.py
erp5/trunk/products/ERP5/mixin/text_convertable.py
Modified: erp5/trunk/products/ERP5/interfaces/text_convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/text_convertable.py?rev=37046&r1=37045&r2=37046&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/text_convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/interfaces/text_convertable.py [utf8] Mon Jul 12 15:04:21 2010
@@ -29,7 +29,23 @@
from zope.interface import Interface
-class ITextConvertable(Interface):
+class ITextConvertableLegacy(Interface):
+ """
+ Legacy ITextConvertable interface specification
+
+ Documents which implement the ITextConvertable interface
+ can be converted to plain text.
+ """
+
+ def asTextContent(**kw):
+ """
+ Converts the current document to plain text
+
+ kw -- optional parameters which can be passed to the
+ conversion engine
+ """
+
+class ITextConvertable(ITextConvertableLegacy):
"""
Text Convertable interface specification
Modified: erp5/trunk/products/ERP5/mixin/text_convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/text_convertable.py?rev=37046&r1=37045&r2=37046&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/text_convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/text_convertable.py [utf8] Mon Jul 12 15:04:21 2010
@@ -27,14 +27,35 @@
#
##############################################################################
+from AccessControl import ClassSecurityInfo
+from Products.ERP5Type import Permissions
+from warnings import warn
+
class TextConvertableMixin:
"""
This class provides a generic implementation of ITextConvertable.
"""
+ # Declarative security
+ security = ClassSecurityInfo()
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'asText')
def asText(self, **kw):
"""
+ Converts the current document to plain text
"""
kw.pop('format', None)
mime, data = self.convert(format='txt', **kw)
return str(data)
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'asTextContent')
+ def asTextContent(self, **kw):
+ """
+ Converts the current document to plain text
+ Backward (legacy) compatibility
+ """
+ warn("asTextContent() function is deprecated. Use asText() instead.", \
+ DeprecationWarning, stacklevel=2)
+ return self.asText(**kw)
More information about the Erp5-report
mailing list