Commit 7f4911a1 authored by Nicolas Dumazet's avatar Nicolas Dumazet

unify getDefaultTransformationValue and getDefaultConversionTransformationValue

Document getDefaultTransformationValue.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33346 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 025f81a2
...@@ -282,7 +282,28 @@ class Resource(XMLMatrix, Variated): ...@@ -282,7 +282,28 @@ class Resource(XMLMatrix, Variated):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getDefaultTransformationValue') '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, transformation_list = self.portal_domains.searchPredicateList(context,
portal_type="Transformation") portal_type="Transformation")
...@@ -302,18 +323,14 @@ class Resource(XMLMatrix, Variated): ...@@ -302,18 +323,14 @@ class Resource(XMLMatrix, Variated):
temporary Transformation: one might want for example, for conversion temporary Transformation: one might want for example, for conversion
purposes, to ignore some (packaging, wrapping, labelling) components purposes, to ignore some (packaging, wrapping, labelling) components
in conversion reports. This method can be used to create a simplified in conversion reports. This method can be used to create a simplified
transformation from the complex transformation returned by transformation from a complex real-world transformation.
getDefaultTransformationValue
""" """
method = context._getTypeBasedMethod(\ method = self._getTypeBasedMethod(\
'getDefaultConversionTransformationValue') 'getDefaultConversionTransformationValue')
if method is not None: if method is not None:
return method() return method()
transformation_list = self.portal_catalog(portal_type="Transformation", return self.getDefaultConversionTransformationValue(context=None)
resource_category_uid=self.getUid())
if len(transformation_list) > 0:
return transformation_list[0].getObject()
#################################################### ####################################################
......
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