From fed08b3e27d898a2dc0bd876f60adc584b0d04a4 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 21 Apr 2009 09:21:56 +0000
Subject: [PATCH] Simplify Selection.__call__ code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26542 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/Selection.py | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/product/ERP5Form/Selection.py b/product/ERP5Form/Selection.py
index 18e2205941..0da60208c7 100644
--- a/product/ERP5Form/Selection.py
+++ b/product/ERP5Form/Selection.py
@@ -205,22 +205,16 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
           del kw['sort_on'] # We should not sort if no sort was defined
         # We should always set selection_name with self.name
         kw['selection_name'] = self.name
-        if method is not None:
-          if callable(method):
-            if self.domain is not None and self.report is not None:
-              result = method(selection_domain = self.domain,
-                              selection_report = self.report, selection=self, **kw)
-            elif self.domain is not None:
-              result = method(selection_domain = self.domain, selection=self, **kw)
-            elif self.report is not None:
-              result = method(selection_report = self.report, selection=self, **kw)
-            else:
-              result = method(selection=self, **kw)
-            return result
-          else:
-            return []
+        kw['selection'] = self
+        if self.domain is not None:
+          kw['selection_domain'] = self.domain
+        if self.report is not None:
+          kw['selection_report'] = self.report
+        if callable(method):
+          result = method(**kw)
         else:
-          return []
+          result = []
+        return result
 
     def __getitem__(self, index, REQUEST=None):
         return self(REQUEST)[index]
-- 
2.30.9