[Erp5-report] r37045 ivan - in /erp5/trunk/products/ERP5: Document/ interfaces/ mixin/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jul 12 14:36:40 CEST 2010


Author: ivan
Date: Mon Jul 12 14:36:37 2010
New Revision: 37045

URL: http://svn.erp5.org?rev=37045&view=rev
Log:
Split IConvertable to IFormatConvertable and IConvertable. Move implementation from abstract Document class to interface (IConvertable) implementation. Adjust interface doc strings accordingly. 

Modified:
    erp5/trunk/products/ERP5/Document/Document.py
    erp5/trunk/products/ERP5/interfaces/convertable.py
    erp5/trunk/products/ERP5/mixin/cached_convertable.py

Modified: erp5/trunk/products/ERP5/Document/Document.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Document.py?rev=37045&r1=37044&r2=37045&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Document.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Document.py [utf8] Mon Jul 12 14:36:37 2010
@@ -1263,42 +1263,3 @@ class Document(PermanentURLMixIn, XMLObj
         # but not in http://www.some.site/at
         base_url = '/'.join(base_url_list[:-1])
     return base_url
-
-  security.declareProtected(Permissions.AccessContentsInformation,
-                            'getTargetFormatItemList')
-  def getTargetFormatItemList(self):
-    """
-      Returns a list of acceptable formats for conversion
-      in the form of tuples (for listfield in ERP5Form)
-
-      NOTE: it is the responsability of the respecive type based script
-      to provide an extensive list of conversion formats.
-    """
-    method = self._getTypeBasedMethod('getTargetFormatItemList',
-              fallback_script_id='Base_getTargetFormatItemList')
-    return method()
-
-  security.declareProtected(Permissions.AccessContentsInformation,
-                            'getTargetFormatTitleList')
-  def getTargetFormatTitleList(self):
-    """
-      Returns a list of acceptable formats for conversion
-    """
-    return map(lambda x: x[0], self.getTargetFormatItemList())
-
-  security.declareProtected(Permissions.AccessContentsInformation,
-                            'getTargetFormatList')
-  def getTargetFormatList(self):
-    """
-      Returns a list of acceptable formats for conversion
-    """
-    return map(lambda x: x[1], self.getTargetFormatItemList())
-
-  security.declareProtected(Permissions.ModifyPortalContent,
-                            'isTargetFormatAllowed')
-  def isTargetFormatAllowed(self, format):
-    """
-      Checks if the current document can be converted
-      into the specified target format.
-    """
-    return format in self.getTargetFormatList()

Modified: erp5/trunk/products/ERP5/interfaces/convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/convertable.py?rev=37045&r1=37044&r2=37045&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/interfaces/convertable.py [utf8] Mon Jul 12 14:36:37 2010
@@ -29,35 +29,14 @@
 
 from zope.interface import Interface
 
-class IConvertable(Interface):
+class IFormatConvertable(Interface):
   """
-  Convertable interface specification
+  Format Convertable interface specification
 
-  Documents which implement IConvertable can be converted
-  to multiple formats. IConvertable also provides 
-  methods to list possible formats which documents can
+  IFormatConvertable provides methods to list possible formats which documents can
   be converted to.
   """
 
-  def convert(format, **kw):
-    """
-    Converts the current document to the specified format
-    taking into account optional parameters. This method
-    returns a tuple of two values: a mime type string and
-    the converted data.
-    
-    This methods raises a ConversionError if the target format
-    is not allowed, or an Unauthorized error if the target format
-    is not permitted.
-
-    format -- the target conversion format specified either as an
-              extension (ex. 'png') or as a mime type
-              string (ex. 'text/plain')
-
-    kw -- optional parameters which can be passed to the
-          conversion engine
-    """
-
   def isTargetFormatAllowed(format):
     """
     Checks if the current document can be converted
@@ -110,3 +89,29 @@ class IConvertable(Interface):
     passed to IConvertable.convert or to IDownloadable.index_html
     """
 
+class IConvertable(IFormatConvertable):
+  """
+  Convertable interface specification
+
+  Documents which implement IConvertable can be converted
+  to multiple formats.
+  """
+
+  def convert(format, **kw):
+    """
+    Converts the current document to the specified format
+    taking into account optional parameters. This method
+    returns a tuple of two values: a mime type string and
+    the converted data.
+    
+    This methods raises a ConversionError if the target format
+    is not allowed, or an Unauthorized error if the target format
+    is not permitted.
+
+    format -- the target conversion format specified either as an
+              extension (ex. 'png') or as a mime type
+              string (ex. 'text/plain')
+
+    kw -- optional parameters which can be passed to the
+          conversion engine
+    """

Modified: erp5/trunk/products/ERP5/mixin/cached_convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/cached_convertable.py?rev=37045&r1=37044&r2=37045&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] Mon Jul 12 14:36:37 2010
@@ -244,3 +244,42 @@ class CachedConvertableMixin:
         self._setContentMd5(md5.new(data).hexdigest()) # Reindex is useless
     else:
       self._setContentMd5(None)
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getTargetFormatItemList')
+  def getTargetFormatItemList(self):
+    """
+      Returns a list of acceptable formats for conversion
+      in the form of tuples (for listfield in ERP5Form)
+
+      NOTE: it is the responsability of the respecive type based script
+      to provide an extensive list of conversion formats.
+    """
+    method = self._getTypeBasedMethod('getTargetFormatItemList',
+              fallback_script_id='Base_getTargetFormatItemList')
+    return method()
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getTargetFormatTitleList')
+  def getTargetFormatTitleList(self):
+    """
+      Returns a list of acceptable formats for conversion
+    """
+    return map(lambda x: x[0], self.getTargetFormatItemList())
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getTargetFormatList')
+  def getTargetFormatList(self):
+    """
+      Returns a list of acceptable formats for conversion
+    """
+    return map(lambda x: x[1], self.getTargetFormatItemList())
+
+  security.declareProtected(Permissions.ModifyPortalContent,
+                            'isTargetFormatAllowed')
+  def isTargetFormatAllowed(self, format):
+    """
+      Checks if the current document can be converted
+      into the specified target format.
+    """
+    return format in self.getTargetFormatList()
\ No newline at end of file




More information about the Erp5-report mailing list