Commit c2768248 authored by Alexandre Boeglin's avatar Alexandre Boeglin

When a field property becomes delegated, field.values and field.tales entries

for this property should be removed (they are no longer required, no need to
export them in bt5 and make the diff less readable).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19113 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 28bc7bae
...@@ -260,6 +260,8 @@ class ProxyField(ZMIField): ...@@ -260,6 +260,8 @@ class ProxyField(ZMIField):
for key, value in result.items(): for key, value in result.items():
if key not in surcharge_list: if key not in surcharge_list:
result.pop(key) result.pop(key)
if key in self.tales:
self.tales.pop(key)
# now do actual update of values # now do actual update of values
values.update(result) values.update(result)
...@@ -337,6 +339,8 @@ class ProxyField(ZMIField): ...@@ -337,6 +339,8 @@ class ProxyField(ZMIField):
for key, value in result.items(): for key, value in result.items():
if key not in surcharge_list: if key not in surcharge_list:
result.pop(key) result.pop(key)
if key in self.values:
self.values.pop(key)
# now do actual update of values # now do actual update of values
tales.update(result) tales.update(result)
......
...@@ -326,6 +326,55 @@ class TestProxyField(unittest.TestCase): ...@@ -326,6 +326,55 @@ class TestProxyField(unittest.TestCase):
# Next, call field which the id is same to the template field's. # Next, call field which the id is same to the template field's.
self.assertEqual('123', proxy_field1.get_value('default')) self.assertEqual('123', proxy_field1.get_value('default'))
def test_dicts_cleared_on_edit(self):
"""
Test that values and tales dicts are cleared when property is switched to
not surcharged.
"""
# create a field
original_field = self.addField(self.container.Base_viewProxyFieldLibrary,
'my_title', 'OrigTitle', 'StringField')
field = self.addField(self.container.Base_view,
'my_dict_test', '', 'ProxyField')
field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary',
field_id='my_title',))
def surcharge_edit():
#surcharge from edit
field._surcharged_edit(dict(title='TestTitle'), ['title'])
self.assertTrue('title' in field.delegated_list)
self.assertEquals(field.values['title'], 'TestTitle')
self.assertTrue('title' not in field.tales)
def delegate_edit():
# delegate the field from edit view
field._surcharged_edit(dict(title='TestTitle'), [])
self.assertTrue('title' not in field.delegated_list)
self.assertTrue('title' not in field.values)
self.assertTrue('title' not in field.tales)
def surcharge_tales():
#surcharge from tales
field._surcharged_tales(dict(title='string:TestTitle'), ['title'])
self.assertTrue('title' in field.delegated_list)
self.assertTrue(field.values['title'], 'OrigTitle')
self.assertEquals(field.tales['title'], 'string:TestTitle')
def delegate_tales():
# delegate the field from tales view
field._surcharged_tales(dict(title='string:TestTitle'), [])
self.assertTrue('title' not in field.delegated_list)
self.assertTrue('title' not in field.values)
self.assertTrue('title' not in field.tales)
surcharge_edit()
delegate_edit()
surcharge_edit()
delegate_tales()
surcharge_tales()
delegate_edit()
surcharge_tales()
delegate_tales()
class TestFieldValueCache(unittest.TestCase): class TestFieldValueCache(unittest.TestCase):
"""Tests field value caching system """Tests field value caching system
......
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