[Erp5-report] r33436 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/Resource.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Mar 5 11:53:01 CET 2010
Author: nicolas.dumazet
Date: Fri Mar 5 11:52:59 2010
New Revision: 33436
URL: http://svn.erp5.org?rev=33436&view=rev
Log:
Split Transformation indexation:
- drop getTransformationRowList that was computing everything
- use instead getTransformationVariationCategoryCartesianProduct that
computes only possible variations, and leave the actual
aggregatedAmountList calls and row generation to activities
triggered by catalog
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=33436&r1=33435&r2=33436&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Resource.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Resource.py [utf8] Fri Mar 5 11:52:59 2010
@@ -300,9 +300,11 @@
if len(transformation_list) > 0:
return transformation_list[0].getObject()
- method = context._getTypeBasedMethod('getDefaultTransformationValue')
- if method is not None:
- return method(context)
+ else:
+ method = context._getTypeBasedMethod('getDefaultTransformationValue')
+ if method is not None:
+ return method(context)
+
method = self._getTypeBasedMethod('getDefaultTransformationValue')
if method is not None:
return method(context)
@@ -335,6 +337,37 @@
return method()
return self.getDefaultTransformationValue(context=None)
+
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'getTransformationVariationCategoryCartesianProduct')
+ def getTransformationVariationCategoryCartesianProduct(self):
+ """
+ Defines which variations are of interest when indexing
+ Transformations related to this resource.
+
+ By default, this returns the cartesian Product of all
+ possible categories using all variation axes.
+
+ Override this to reduce the number of indexed rows, and/or
+ if some variation axes do not matter when displaying
+ Transformed inventories.
+
+ XXX This should use variated_range mixin when available
+ """
+ method = self._getTypeBasedMethod(\
+ 'getTransformationVariationCategoryCartesianProduct')
+ if method is not None:
+ return method()
+
+ variation_list_list = []
+ for base_variation in self.getVariationBaseCategoryList():
+ variation_list = self.getVariationCategoryList( \
+ base_category_list=(base_variation,))
+ if len(variation_list) > 0:
+ variation_list_list.append(variation_list)
+
+ return cartesianProduct(variation_list_list)
####################################################
@@ -996,48 +1029,6 @@
return row_list
security.declareProtected(Permissions.AccessContentsInformation,
- 'getTransformationRowList')
- def getTransformationRowList(self):
- """
- Returns a list of rows to insert in the transformation table.
- Used by z_catalog_transformation_list
- """
- from Products.ERP5Type.Document import newTempMovement
- resource_uid = self.getUid()
-
- variation_list_list = []
- for base_variation in self.getVariationBaseCategoryList():
- variation_list = self.getVariationCategoryList( \
- base_category_list=(base_variation,))
- if len(variation_list) > 0:
- variation_list_list.append(variation_list)
-
- transformation = self.getDefaultConversionTransformationValue()
-
- kw = dict(resource=self.getRelativeUrl(), quantity=1.0)
- row_list = []
- for i, variation_list in enumerate(cartesianProduct(variation_list_list)):
- # We must have an unique movement ID for each movement, or we might
- # hit the cache due to similar physical paths
- movement = newTempMovement(self, 'temp_%s' % i,
- variation_category_list=variation_list,
- **kw)
-
- base_row = dict(uid=resource_uid,
- variation_text=movement.getVariationText())
- for amount in transformation.getAggregatedAmountList(movement):
- transformed_resource_uid = amount.getResourceUid()
- quantity = amount.getQuantity()
- if transformed_resource_uid is not None and quantity is not None:
- row = base_row.copy()
- row.update(transformed_uid=transformed_resource_uid,
- transformed_variation_text=amount.getVariationText(),
- quantity=quantity)
- row_list.append(row)
- return row_list
-
-
- security.declareProtected(Permissions.AccessContentsInformation,
'getMeasureRowList')
def getMeasureRowList(self):
"""
More information about the Erp5-report
mailing list