From f0cb3704990032a8408086af11066f95c841ea04 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 18 Jul 2008 16:39:03 +0000
Subject: [PATCH] Performance improvements: - DO NOT use getObject to then just
 get an UID. It is ready to use in SQL result. This saves a roundtrip to ZODB
 (which can be in a remote ZEO server). - DO NOT use getXXXUid() to then feed
 the uid to catalog to get the real object. Uid _has_ been fetched from the
 actual object in the accessor anyway. So just grab actual objects, and fetch
 uids from them when needed. This saves a roundtrip (...per iteration !) to
 catalog. - Use "IN" instead of "OR" with equality in SQL query (minor
 improvement compared to the 2 above)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22567 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../CheckbookDelivery_checkAggregateStockList.xml   | 13 ++++---------
 bt5/erp5_banking_check/bt/revision                  |  2 +-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookDelivery_checkAggregateStockList.xml b/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookDelivery_checkAggregateStockList.xml
index 9e754b91ea..96be7f5a43 100644
--- a/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookDelivery_checkAggregateStockList.xml
+++ b/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookDelivery_checkAggregateStockList.xml
@@ -68,14 +68,12 @@
             <value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
 from Products.ERP5Type.Message import Message\n
 \n
-current_tracking_list = [x.getObject() for x in context.portal_simulation.getCurrentTrackingList(\n
+aggregate_uid_list = [x.uid for x in context.portal_simulation.getCurrentTrackingList(\n
                          at_date=at_date, node=node_url,\n
-                         where_expression="item_catalog.portal_type=\'Check\' or item_catalog.portal_type=\'Checkbook\'")]\n
-aggregate_uid_list = [x.uid for x in current_tracking_list]\n
+                         where_expression="item_catalog.portal_type IN (\'Check\', \'Checkbook\')")]\n
 for line in context.getMovementList():\n
-  for aggregate_uid in line.getAggregateUidList():\n
-    if aggregate_uid not in aggregate_uid_list:\n
-      aggregate_value = context.portal_catalog(uid=aggregate_uid)[0].getObject()\n
+  for aggregate_value in line.getAggregateValueList():\n
+    if aggregate_value.getUid() not in aggregate_uid_list:\n
       reference = aggregate_value.getReference()\n
       if reference is None:\n
         reference = \'%s - %s\' % (aggregate_value.getReferenceRangeMin() or \'\', aggregate_value.getReferenceRangeMax() or \'\')\n
@@ -142,11 +140,8 @@ for line in context.getMovementList():\n
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>x</string>
-                            <string>current_tracking_list</string>
                             <string>aggregate_uid_list</string>
                             <string>line</string>
-                            <string>aggregate_uid</string>
-                            <string>_getitem_</string>
                             <string>aggregate_value</string>
                             <string>reference</string>
                             <string>None</string>
diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision
index 50b04dff0e..cdf1f34dc9 100644
--- a/bt5/erp5_banking_check/bt/revision
+++ b/bt5/erp5_banking_check/bt/revision
@@ -1 +1 @@
-402
\ No newline at end of file
+403
\ No newline at end of file
-- 
2.30.9