Commit 0fb1493b authored by Jérome Perrin's avatar Jérome Perrin

ListBox.get_value(render_format='list') was not working properly with

proxyfield, because the renderer class was using the target listbox field.
Handle the case of proxy field specificly so that the original proxyfield is
used by the renderer, and calls to get_value are looked up properly.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15729 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4619c632
......@@ -3013,8 +3013,15 @@ class ListBox(ZMIField):
def get_value(self, id, **kw):
if (id == 'default'):
if (kw.get('render_format') in ('list', )):
return self.widget.render(self, self.generate_field_key(), None,
kw.get('REQUEST'),
request = kw.get('REQUEST', None)
if request is None:
request = get_request()
# here the field can be a a proxyfield target, in this case just find
# back the original proxy field so that renderer's calls to .get_value
# are called on the proxyfield.
field = request.get('field__proxyfield_%s_%s' % (self.id, id), self)
return self.widget.render(field, self.generate_field_key(), None,
request,
render_format=kw.get('render_format'))
else:
return None
......
......@@ -40,6 +40,7 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript
from ZPublisher.HTTPRequest import FileUpload
from StringIO import StringIO
from Products.ERP5Form.Selection import Selection
from Products.ERP5Form.Form import ERP5Form
class DummyFieldStorage:
......@@ -331,6 +332,44 @@ return []
html = listbox.render(REQUEST=request)
self.failUnless('Object Title' in html, html)
def test_ProxyFieldRenderFormatLines(self):
# tests that listbox default value in render_format=list mode is
# compatible with proxy field.
portal = self.getPortal()
portal.ListBoxZuite_reset()
form = portal.FooModule_viewFooList
listbox = form.listbox
listbox.ListBox_setPropertyList(
field_list_method='contentValues',
field_columns=['listbox_value | Title',],)
# create a form, to store our proxy field inside
portal._setObject('Test_view',
ERP5Form('Test_view', 'View'))
portal.Test_view.manage_addField('listbox', 'listbox', 'ProxyField')
proxy_field = portal.Test_view.listbox
proxy_field.manage_edit_xmlrpc(dict(
form_id=form.getId(), field_id='listbox',
columns=[('proxy_value', 'Proxy')]))
# this proxy field will not delegate its "columns" value
proxy_field._surcharged_edit(dict(columns=[('proxy_value', 'Proxy')]),
['columns'])
request = get_request()
request['here'] = portal.foo_module
line_list = proxy_field.get_value('default',
render_format='list', REQUEST=request)
self.failUnless(isinstance(line_list, list))
title_line = line_list[0]
self.failUnless(title_line.isTitleLine())
# title of columns is the value overloaded by the proxy field.
self.assertEquals([('proxy_value', 'Proxy')],
title_line.getColumnItemList())
if __name__ == '__main__':
framework()
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