From 2c0a145b290fa8e22956258390fb1882a8b2f08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 19 Nov 2007 10:02:09 +0000 Subject: [PATCH] Add API on ProxyField to edit surcharged values, similar to manage_edit_xmlrpc git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17670 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/ProxyField.py | 15 +++++++++++++++ product/ERP5Form/tests/testFields.py | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/product/ERP5Form/ProxyField.py b/product/ERP5Form/ProxyField.py index a128a95ab1..94e092ed12 100644 --- a/product/ERP5Form/ProxyField.py +++ b/product/ERP5Form/ProxyField.py @@ -219,6 +219,21 @@ class ProxyField(ZMIField): return self.manage_main(self, REQUEST, manage_tabs_message=message) + def manage_edit_surcharged_xmlrpc(self, mapping): + """Edit surcharged properties + This method is similar to manage_edit_xmlrpc, and it marks the properties + as not delegated. + """ + self._surcharged_edit(mapping, mapping.keys()) + + def manage_tales_surcharged_xmlrpc(self, mapping): + """Edit surcharged TALES + This method is similar to manage_tales_xmlrpc, and it marks the TALES + properties as not delegated. + """ + self._surcharged_tales(mapping, mapping.keys()) + + def _surcharged_edit(self, result, surcharge_list): # first check for any changes values = self.values diff --git a/product/ERP5Form/tests/testFields.py b/product/ERP5Form/tests/testFields.py index c432f6621e..850a02d28c 100644 --- a/product/ERP5Form/tests/testFields.py +++ b/product/ERP5Form/tests/testFields.py @@ -270,6 +270,25 @@ class TestProxyField(unittest.TestCase): # and validate self.container.Base_view.validate_all_to_request(dict()) + def test_manage_edit_surcharged_xmlrpc(self): + # manage_edit_surcharged_xmlrpc is a method to edit proxyfields + # programmatically + original_field = self.addField(self.container.Base_viewProxyFieldLibrary, + 'my_string', 'String', 'StringField') + proxy_field = self.addField(self.container.Base_view, + 'my_String', '', 'ProxyField') + proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary', + field_id='my_date',)) + + proxy_field.manage_edit_surcharged_xmlrpc(dict(title='Title')) + self.assertFalse(proxy_field.is_delegated('title')) + self.assertEquals('Title', proxy_field.get_value('title')) + + # beware that all values that are not passed in the mapping will be + # delegated again, regardless of the old state. + proxy_field.manage_edit_surcharged_xmlrpc(dict()) + self.assertTrue(proxy_field.is_delegated('title')) + class TestFieldValueCache(unittest.TestCase): """Tests field value caching system -- 2.30.9