[Erp5-report] r17537 - in /erp5/trunk/products/ERP5Form: ProxyField.py tests/testFields.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 12 17:06:13 CET 2007


Author: jerome
Date: Mon Nov 12 17:06:13 2007
New Revision: 17537

URL: http://svn.erp5.org?rev=17537&view=rev
Log:
Get the 'sub_form' attribute dynamically from the template field.
Before that the text version of the sub_form was stored on the proxy field instance.
If you want to use list datetime fields, I'll add a note on UpgradeNote wiki page.


Modified:
    erp5/trunk/products/ERP5Form/ProxyField.py
    erp5/trunk/products/ERP5Form/tests/testFields.py

Modified: erp5/trunk/products/ERP5Form/ProxyField.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ProxyField.py?rev=17537&r1=17536&r2=17537&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ProxyField.py (original)
+++ erp5/trunk/products/ERP5Form/ProxyField.py Mon Nov 12 17:06:13 2007
@@ -367,6 +367,11 @@
         break
       field = template_field
     return template_field
+
+  def _aq_dynamic(self, name):
+    if name == 'sub_form':
+      return self.getTemplateField().sub_form
+    return None
 
   security.declareProtected('Access contents information', 
                             'is_delegated')

Modified: erp5/trunk/products/ERP5Form/tests/testFields.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testFields.py?rev=17537&r1=17536&r2=17537&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testFields.py (original)
+++ erp5/trunk/products/ERP5Form/tests/testFields.py Mon Nov 12 17:06:13 2007
@@ -50,6 +50,7 @@
 from Testing import ZopeTestCase
 ZopeTestCase.installProduct('ERP5Form')
 
+from Acquisition import aq_base
 from Products.Formulator.StandardFields import FloatField
 from Products.Formulator.StandardFields import StringField
 from Products.Formulator.StandardFields import DateTimeField
@@ -251,6 +252,24 @@
     self.assertEquals(other_field, proxy_field.getTemplateField())
     self.assertEquals('Other', proxy_field.get_value('title'))
 
+  def test_proxy_to_date_time_field(self):
+    # date time fields are specific, because they use a 'sub_form', we must
+    # make sure this works as expected
+    original_field = self.addField(self.container.Base_viewProxyFieldLibrary,
+                                   'my_date', 'Date', 'DateTimeField')
+    original_field.manage_edit_xmlrpc(dict(required=0))
+    proxy_field = self.addField(self.container.Base_view,
+                                'my_date', 'Date', 'ProxyField')
+    proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary',
+                                        field_id='my_date',))
+    self.assertTrue(hasattr(proxy_field, 'sub_form'))
+    self.assertTrue(aq_base(proxy_field.sub_form) is
+                      aq_base(original_field.sub_form))
+    # we can render
+    proxy_field.render()
+    # and validate
+    self.container.Base_view.validate_all_to_request(dict())
+    
 
 class TestFieldValueCache(unittest.TestCase):
   """Tests field value caching system




More information about the Erp5-report mailing list