Commit 8515c6e7 authored by Alexandre Boeglin's avatar Alexandre Boeglin

* 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
parent 01c8cf1b
...@@ -59,17 +59,16 @@ try: ...@@ -59,17 +59,16 @@ try:
except NameError: except NameError:
from sets import Set as set from sets import Set as set
class ObjectValuesWrapper: class ListMethodWrapper:
"""This class wraps objectValues so that objectValues behaves like portal_catalog. """This class wraps list methods so that they behave like portal_catalog.
""" """
method_name = __name__ = 'objectValues' def __init__(self, context, method_name):
def __init__(self, context):
self.context = context self.context = context
self.method_name = self.__name__ = method_name
def __call__(self, *args, **kw): def __call__(self, *args, **kw):
brain_list = [] 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 = ZSQLBrain(None, None).__of__(obj)
brain.uid = obj.getUid() brain.uid = obj.getUid()
brain.path = obj.getPath() brain.path = obj.getPath()
...@@ -1025,8 +1024,8 @@ class ListBoxRenderer: ...@@ -1025,8 +1024,8 @@ class ListBoxRenderer:
""" """
list_method_name = self.getListMethodName() list_method_name = self.getListMethodName()
if list_method_name == 'objectValues': if list_method_name in ('objectValues', 'contentValues'):
list_method = ObjectValuesWrapper(self.getContext()) list_method = ListMethodWrapper(self.getContext(), list_method_name)
elif list_method_name is not None: elif list_method_name is not None:
try: try:
list_method = getattr(self.getContext(), list_method_name) list_method = getattr(self.getContext(), list_method_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment