[Erp5-report] r15729 - in /erp5/trunk/products/ERP5Form: ListBox.py tests/testListBox.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Aug 17 16:00:17 CEST 2007
Author: jerome
Date: Fri Aug 17 16:00:17 2007
New Revision: 15729
URL: http://svn.erp5.org?rev=15729&view=rev
Log:
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.
Modified:
erp5/trunk/products/ERP5Form/ListBox.py
erp5/trunk/products/ERP5Form/tests/testListBox.py
Modified: erp5/trunk/products/ERP5Form/ListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ListBox.py?rev=15729&r1=15728&r2=15729&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ListBox.py (original)
+++ erp5/trunk/products/ERP5Form/ListBox.py Fri Aug 17 16:00:17 2007
@@ -3013,8 +3013,15 @@
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
Modified: erp5/trunk/products/ERP5Form/tests/testListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testListBox.py?rev=15729&r1=15728&r2=15729&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testListBox.py (original)
+++ erp5/trunk/products/ERP5Form/tests/testListBox.py Fri Aug 17 16:00:17 2007
@@ -40,6 +40,7 @@
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 @@
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:
More information about the Erp5-report
mailing list