From bfb0ba58d18fc33b1a1d19d868db7d88bf38f3ac Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 7 Dec 2009 15:42:34 +0000
Subject: [PATCH] some divergence testers can be only for matching, not for
 divergence testing. so we need a way to recognise if a tester is for
 divergence testing or not.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31126 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../ERP5/PropertySheet/DivergenceTester.py    |  5 +++++
 product/ERP5/mixin/rule.py                    | 19 +++++++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/product/ERP5/PropertySheet/DivergenceTester.py b/product/ERP5/PropertySheet/DivergenceTester.py
index 01b497b678..e1968aadd1 100644
--- a/product/ERP5/PropertySheet/DivergenceTester.py
+++ b/product/ERP5/PropertySheet/DivergenceTester.py
@@ -39,6 +39,11 @@ class DivergenceTester:
        'type'        : 'lines',
        'default'     : (),
        'mode'        : 'w' },
+    {  'id'          : 'testing_provider',
+       'description' : 'Defines whether a divergence tester acts as a testing provider.',
+       'type'        : 'boolean',
+       'default'     : 0,
+       'mode'        : 'rw' },
     {  'id'          : 'matching_provider',
        'description' : 'Defines whether a divergence tester acts as a matching provider.',
        'type'        : 'boolean',
diff --git a/product/ERP5/mixin/rule.py b/product/ERP5/mixin/rule.py
index 4d8b7b0489..b37414d2c5 100644
--- a/product/ERP5/mixin/rule.py
+++ b/product/ERP5/mixin/rule.py
@@ -235,20 +235,14 @@ class RuleMixin:
     """
     raise NotImplementedError
 
-  def _getDivergenceTesterList(self, exclude_quantity=True):
+  def _getDivergenceTesterList(self):
     """
     Return the applicable divergence testers which must
-    be used to test movement divergence.
-
-    exclude_quantity -- if set to true, do not consider
-                        quantity divergence testers
+    be used to test movement divergence. (ie. not all
+    divergence testers of the Rule)
     """
-    tester_list = self.objectValues(
-      portal_type=self.getPortalDivergenceTesterTypeList())
-    if exclude_quantity:
-      return [x for x in tester_list if x.getTestedProperty() != 'quantity']
-    else:
-      return tester_list
+    return filter(lambda x:x.isTestingProvider(), self.objectValues(
+      portal_type=self.getPortalDivergenceTesterTypeList()))
 
   def _getMatchingTesterList(self):
     """
@@ -256,7 +250,8 @@ class RuleMixin:
     be used to match movements and build the diff (ie.
     not all divergence testers of the Rule)
     """
-    raise NotImplementedError
+    return filter(lambda x:x.isMatchingProvider(), self.objectValues(
+      portal_type=self.getPortalDivergenceTesterTypeList()))
 
   def _getQuantityTesterList(self):
     """
-- 
2.30.9