[Erp5-report] r33346 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/Resource.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Mar 4 03:10:52 CET 2010


Author: nicolas.dumazet
Date: Thu Mar  4 03:10:51 2010
New Revision: 33346

URL: http://svn.erp5.org?rev=33346&view=rev
Log:
unify getDefaultTransformationValue and getDefaultConversionTransformationValue

Document getDefaultTransformationValue.

Modified:
    erp5/trunk/products/ERP5/Document/Resource.py

Modified: erp5/trunk/products/ERP5/Document/Resource.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Resource.py?rev=33346&r1=33345&r2=33346&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Resource.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Resource.py [utf8] Thu Mar  4 03:10:51 2010
@@ -282,7 +282,28 @@
 
     security.declareProtected(Permissions.AccessContentsInformation,
                               'getDefaultTransformationValue')
-    def getDefaultTransformationValue(self, context):
+    def getDefaultTransformationValue(self, context=None):
+      """
+      If context is None, returns the first available transformation that
+      use self as a Resource.
+
+      Otherwise, context is used as a Predicate to match Transformations.
+      If the search returns several candidates due to a relaxed Predicate,
+      the first item is returned arbitrarily.
+      """
+      if context is None:
+        transformation_list = self.portal_catalog(portal_type="Transformation",
+                                            resource_category_uid=self.getUid())
+        if len(transformation_list) > 0:
+          return transformation_list[0].getObject()
+
+      method = context._getTypeBasedMethod('getDefaultTransformationValue')
+      if method is not None:
+        return method(context)
+      method = self._getTypeBasedMethod('getDefaultTransformationValue')
+      if method is not None:
+        return method(context)
+
       transformation_list = self.portal_domains.searchPredicateList(context,
                                 portal_type="Transformation")
 
@@ -302,18 +323,14 @@
       temporary Transformation: one might want for example, for conversion
       purposes, to ignore some (packaging, wrapping, labelling) components
       in conversion reports. This method can be used to create a simplified
-      transformation from the complex transformation returned by
-      getDefaultTransformationValue
-      """
-      method = context._getTypeBasedMethod(\
+      transformation from a complex real-world transformation.
+      """
+      method = self._getTypeBasedMethod(\
                         'getDefaultConversionTransformationValue')
       if method is not None:
         return method()
 
-      transformation_list = self.portal_catalog(portal_type="Transformation",
-                                            resource_category_uid=self.getUid())
-      if len(transformation_list) > 0:
-        return transformation_list[0].getObject()
+      return self.getDefaultConversionTransformationValue(context=None)
 
 
     ####################################################




More information about the Erp5-report mailing list