From 8515c6e7d252236fd28454362795a24ba0fd5320 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Tue, 26 Feb 2008 11:01:13 +0000
Subject: [PATCH] * rename ObjectValuesWrapper to ListMethodWrapper * wrap
 'contentValues' as well as 'objectValues'

This allows acquired properties to be displayed in a listbox, when
contentValues is used as the list method.


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

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index 8418afc636..328a54b0cb 100644
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -59,17 +59,16 @@ try:
 except NameError:
   from sets import Set as set
 
-class ObjectValuesWrapper:
-  """This class wraps objectValues so that objectValues behaves like portal_catalog.
+class ListMethodWrapper:
+  """This class wraps list methods so that they behave like portal_catalog.
   """
-  method_name = __name__ = 'objectValues'
-
-  def __init__(self, context):
+  def __init__(self, context, method_name):
     self.context = context
+    self.method_name = self.__name__ = method_name
 
   def __call__(self, *args, **kw):
     brain_list = []
-    for obj in self.context.objectValues(*args, **kw):
+    for obj in getattr(self.context, self.method_name)(*args, **kw):
       brain = ZSQLBrain(None, None).__of__(obj)
       brain.uid = obj.getUid()
       brain.path = obj.getPath()
@@ -1025,8 +1024,8 @@ class ListBoxRenderer:
     """
     list_method_name = self.getListMethodName()
 
-    if list_method_name == 'objectValues':
-      list_method = ObjectValuesWrapper(self.getContext())
+    if list_method_name in ('objectValues', 'contentValues'):
+      list_method = ListMethodWrapper(self.getContext(), list_method_name)
     elif list_method_name is not None:
       try:
         list_method = getattr(self.getContext(), list_method_name)
-- 
2.30.9