Commit 78154b52 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Wrap the result of objectValues by ZSQLBrain.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4098 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eb65c443
...@@ -40,6 +40,7 @@ from Products.ERP5Type.Utils import getPath ...@@ -40,6 +40,7 @@ from Products.ERP5Type.Utils import getPath
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from copy import copy from copy import copy
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from Acquisition import aq_base, aq_inner, aq_parent, aq_self from Acquisition import aq_base, aq_inner, aq_parent, aq_self
from zLOG import LOG from zLOG import LOG
...@@ -50,6 +51,23 @@ from Products.PythonScripts.Utility import allow_class ...@@ -50,6 +51,23 @@ from Products.PythonScripts.Utility import allow_class
import random import random
import md5 import md5
class ObjectValuesWrapper:
"""This class wraps objectValues so that objectValues behaves like portal_catalog.
"""
method_name = __name__ = 'objectValues'
def __init__(self, context):
self.context = context
def __call__(self, *args, **kw):
brain_list = []
for obj in self.context.objectValues(*args, **kw):
brain = ZSQLBrain(None, None).__of__(obj)
brain.uid = obj.getUid()
brain.path = obj.getPath()
brain_list.append(brain)
return brain_list
def getAsList(a): def getAsList(a):
l = [] l = []
for e in a: for e in a:
...@@ -747,7 +765,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -747,7 +765,7 @@ class ListBoxWidget(Widget.Widget):
if hasattr(list_method, 'method_name'): if hasattr(list_method, 'method_name'):
if list_method.method_name == 'objectValues': if list_method.method_name == 'objectValues':
list_method = here.objectValues list_method = ObjectValuesWrapper(here)
kw = copy(params) kw = copy(params)
kw['spec'] = filtered_meta_types kw['spec'] = filtered_meta_types
else: else:
......
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