[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/Views/Browser/tests - testBrowserWidget.py:1.3.6.1 testCheckBoxWidget.py:1.2.6.1 testFileWidget.py:1.2.6.1 testFormView.py:1.15.4.1 testListWidget.py:1.4.6.1 testMultiCheckboxWidget.py:1.4.6.1 testMultiListWidget.py:1.4.6.1 testPasswordWidget.py:1.2.6.1 testRadioWidget.py:1.4.6.1 testTextAreaWidget.py:1.2.6.1 testTextWidget.py:1.2.6.1

Jim Fulton jim@zope.com
Mon, 28 Oct 2002 11:51:25 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv29831/lib/python/Zope/App/Forms/Views/Browser/tests

Modified Files:
      Tag: Zope3-Bangalore-TTW-Branch
	testBrowserWidget.py testCheckBoxWidget.py testFileWidget.py 
	testFormView.py testListWidget.py testMultiCheckboxWidget.py 
	testMultiListWidget.py testPasswordWidget.py 
	testRadioWidget.py testTextAreaWidget.py testTextWidget.py 
Log Message:
Changed the form widget interfaces:

- Widgets now have a setData method for setting their initial 
  data. This is the data that will be displayed absent user input.

- Browser widgets should now be called without arguments to render.
  If there is initial data, it should be passed with setData prior to
  rendering.  This change was made to allow widgets to be rendered in
  ZPT without resorting to python expressions.

- Browser widgets now have a 'hidden' method to render the widgets as
  hidden fields. The hidden method is called without arguments. 
  
- Removed the unused, except in tests, hidden attribute that was,
  presumably, a flag indicating that a widget should render as hidden.

- Deprecated the render and renderHidden methods. These need to be
  refactored out after the Zope3-Bangalore-TTW-Branch branch is merged
  into the trunk. 

- Changed the render method (back) so that it requires a value
  argument. 



=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py 1.3 => 1.3.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py:1.3	Wed Sep  4 09:44:24 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testBrowserWidget.py	Mon Oct 28 11:51:24 2002
@@ -20,6 +20,8 @@
 
 class Field:
     """Field Stub """
+    __name__ = 'foo'
+    
     def getName(self):
         return 'foo'
     
@@ -28,7 +30,7 @@
 
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = BrowserWidget(field, request)
 
     def _verifyResult(self, result, check_list):
@@ -40,12 +42,11 @@
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'text')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
 
     def testRender(self):
         value = 'Foo Value'
-        check_list = ('type="text"', 'name="field_foo"', 'value="Foo Value"')
+        check_list = ('type="text"', 'name="field.foo"', 'value="Foo Value"')
         self._verifyResult(self._widget.render(value), check_list)
         check_list = ('type="hidden"',) + check_list[1:]
         self._verifyResult(self._widget.renderHidden(value), check_list)


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testCheckBoxWidget.py 1.2 => 1.2.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testCheckBoxWidget.py:1.2	Wed Jul 17 12:54:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testCheckBoxWidget.py	Mon Oct 28 11:51:24 2002
@@ -24,20 +24,19 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = CheckBoxWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'checkbox')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('default'), 0)
 
     def testRender(self):
         value = 1
-        check_list = ('type="checkbox"', 'name="field_foo"',
+        check_list = ('type="checkbox"', 'name="field.foo"',
                       'checked="checked"')
         self._verifyResult(self._widget.render(value), check_list)
         value = 0


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFileWidget.py 1.2 => 1.2.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFileWidget.py:1.2	Wed Jul 17 12:54:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFileWidget.py	Mon Oct 28 11:51:24 2002
@@ -24,14 +24,13 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = FileWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'file')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('default'), '')
         self.assertEqual(self._widget.getValue('displayWidth'), 20)
@@ -39,7 +38,7 @@
 
     def testRender(self):
         value = 'Foo Value'
-        check_list = ('type="file"', 'name="field_foo"', 'size="20"')
+        check_list = ('type="file"', 'name="field.foo"', 'size="20"')
         self._verifyResult(self._widget.render(value), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]
         self._verifyResult(self._widget.renderHidden(value), check_list)


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFormView.py 1.15 => 1.15.4.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFormView.py:1.15	Fri Oct  4 14:37:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFormView.py	Mon Oct 28 11:51:24 2002
@@ -37,9 +37,9 @@
         viewService = self.getViewService()
         viewService.provideView(IBytes, 'widget', IBrowserView, [TextWidget])
         request = SchemaTestObject.TestBrowserRequest(
-            {'field_id': '1', 'field_title': 'Test New',
-             'field_creator': 'srichter@cbu.edu',
-             'field_data': StringIO('Data')})
+            {'field.id': '1', 'field.title': 'Test New',
+             'field.creator': 'srichter@cbu.edu',
+             'field.data': StringIO('Data')})
         self._form = SchemaTestObject.EditFactory(request=request)
         self.__data = {'id': 1,
                        'title': 'Test New',
@@ -99,11 +99,11 @@
     def testRenderField(self):
         field = SchemaTestObject.ITestObject.getDescriptionFor('id')
         self.assertEqual(
-            '<input name="field_id" type="text" value="5" size="10"  />',
+            '<input name="field.id" type="text" value="5" size="10"  />',
             self._form.renderField(field))
 
         field = SchemaTestObject.ITestObject.getDescriptionFor('creator')
-        self.assertEqual('<input name="field_creator" type="text" '
+        self.assertEqual('<input name="field.creator" type="text" '
                          'value="strichter@yahoo.com" size="30"  />',
                          self._form.renderField(field))
 


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testListWidget.py 1.4 => 1.4.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testListWidget.py:1.4	Wed Sep  4 09:44:24 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testListWidget.py	Mon Oct 28 11:51:24 2002
@@ -23,6 +23,8 @@
     """Field Stub """
     items = [('foo', 'Foo'), ('bar', 'Bar')]
 
+    __name__ = 'foo'
+
     def getName(self):
         return 'foo'
     
@@ -33,12 +35,11 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = ListWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('items'), [])
         self.assertEqual(self._widget.getValue('firstItem'), 0)
@@ -47,11 +48,12 @@
 
     def testRenderItem(self):
         check_list = ('option', 'value="foo"', 'Foo')
-        self._verifyResult(self._widget.renderItem('Foo', 'foo', 'bar', None),
-                           check_list)
+        self._verifyResult(
+            self._widget.renderItem('Foo', 'foo', 'field.bar', None),
+            check_list)
         check_list += ('selected="selected"',)
         self._verifyResult(
-            self._widget.renderSelectedItem('Foo', 'foo', 'bar', None),
+            self._widget.renderSelectedItem('Foo', 'foo', 'field.bar', None),
             check_list)
 
 
@@ -64,12 +66,12 @@
 
     def testRender(self):
         value = 'foo'
-        check_list = ('select', 'name="field_foo"', 'size="5"', 
+        check_list = ('select', 'name="field.foo"', 'size="5"', 
                       'option', 'value="foo"', '>Foo<',
                       'value="foo"', '>Bar<', 'selected="selected"')
         self._verifyResult(self._widget.render(value), check_list)
 
-        check_list = ('type="hidden"', 'name="field_foo"', 'value="foo"')
+        check_list = ('type="hidden"', 'name="field.foo"', 'value="foo"')
         self._verifyResult(self._widget.renderHidden(value), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiCheckboxWidget.py 1.4 => 1.4.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiCheckboxWidget.py:1.4	Wed Sep  4 09:44:24 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiCheckboxWidget.py	Mon Oct 28 11:51:24 2002
@@ -23,6 +23,8 @@
     """Field Stub """
     items = [('foo1', 'Foo'), ('bar1', 'Bar')]
 
+    __name__ = 'foo'
+
     def getName(self):
         return 'foo'
     
@@ -34,30 +36,30 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = MultiCheckBoxWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('items'), [])
         self.assertEqual(self._widget.getValue('orientation'), 'vertical')
 
 
     def testRenderItem(self):
-        check_list = ('type="checkbox"', 'name="field_bar"', 'value="foo"',
+        check_list = ('type="checkbox"', 'name="field.bar"', 'value="foo"',
                       'Foo')
-        self._verifyResult(self._widget.renderItem('Foo', 'foo', 'bar', None),
-                           check_list)
+        self._verifyResult(
+            self._widget.renderItem('Foo', 'foo', 'field.bar', None),
+            check_list)
         check_list += ('checked="checked"',)
         self._verifyResult(
-            self._widget.renderSelectedItem('Foo', 'foo', 'bar', None),
+            self._widget.renderSelectedItem('Foo', 'foo', 'field.bar', None),
             check_list)
 
 
     def testRenderItems(self):
-        check_list = ('type="checkbox"', 'name="field_foo"', 'value="bar1"',
+        check_list = ('type="checkbox"', 'name="field.foo"', 'value="bar1"',
                       'Bar', 'value="foo1"', 'Foo', 'checked="checked"')
         self._verifyResult('\n'.join(self._widget.renderItems('bar1')),
                            check_list)
@@ -65,11 +67,11 @@
 
     def testRender(self):
         value = 'bar1'
-        check_list = ('type="checkbox"', 'name="field_foo"', 'value="bar1"',
+        check_list = ('type="checkbox"', 'name="field.foo"', 'value="bar1"',
                       'Bar', 'value="foo1"', 'Foo', 'checked="checked"')
         self._verifyResult(self._widget.render(value), check_list)
 
-        check_list = ('type="hidden"', 'name="field_foo"', 'value="bar1"')
+        check_list = ('type="hidden"', 'name="field.foo"', 'value="bar1"')
         self._verifyResult(self._widget.renderHidden(value), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiListWidget.py 1.4 => 1.4.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiListWidget.py:1.4	Wed Sep  4 09:44:24 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testMultiListWidget.py	Mon Oct 28 11:51:24 2002
@@ -23,6 +23,8 @@
     """Field Stub """
     items = [('foo', 'Foo'), ('bar', 'Bar')]
 
+    __name__ = 'foo'
+
     def getName(self):
         return 'foo'
     
@@ -34,13 +36,12 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = MultiListWidget(field, request)
 
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('items'), [])
         self.assertEqual(self._widget.getValue('size'), 5)
@@ -48,11 +49,12 @@
 
     def testRenderItem(self):
         check_list = ('option', 'value="foo"', 'Foo')
-        self._verifyResult(self._widget.renderItem('Foo', 'foo', 'bar', None),
-                           check_list)
+        self._verifyResult(
+            self._widget.renderItem('Foo', 'foo', 'field.bar', None),
+            check_list)
         check_list += ('selected="selected"',)
         self._verifyResult(
-            self._widget.renderSelectedItem('Foo', 'foo', 'bar', None),
+            self._widget.renderSelectedItem('Foo', 'foo', 'field.bar', None),
             check_list)
 
 
@@ -65,13 +67,13 @@
 
     def testRender(self):
         value = 'foo'
-        check_list = ('select', 'name="field_foo"', 'size="5"', 
+        check_list = ('select', 'name="field.foo"', 'size="5"', 
                       'option', 'value="foo"', '>Foo<',
                       'value="foo"', '>Bar<', 'selected="selected"',
                       'multiple="multiple"')
         self._verifyResult(self._widget.render(value), check_list)
 
-        check_list = ('type="hidden"', 'name="field_foo"', 'value="foo"')
+        check_list = ('type="hidden"', 'name="field.foo"', 'value="foo"')
         self._verifyResult(self._widget.renderHidden(value), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testPasswordWidget.py 1.2 => 1.2.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testPasswordWidget.py:1.2	Wed Jul 17 12:54:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testPasswordWidget.py	Mon Oct 28 11:51:24 2002
@@ -24,14 +24,13 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = PasswordWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'password')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('default'), '')
         self.assertEqual(self._widget.getValue('displayWidth'), 20)
@@ -39,7 +38,7 @@
 
     def testRender(self):
         value = 'Foo Value'
-        check_list = ('type="password"', 'name="field_foo"',
+        check_list = ('type="password"', 'name="field.foo"',
                       'value="Foo Value"', 'size="20"')
         self._verifyResult(self._widget.render(value), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testRadioWidget.py 1.4 => 1.4.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testRadioWidget.py:1.4	Wed Sep  4 09:44:24 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testRadioWidget.py	Mon Oct 28 11:51:24 2002
@@ -23,6 +23,8 @@
     """Field Stub """
     items = [('foo1', 'Foo'), ('bar1', 'Bar')]
 
+    __name__ = 'foo'
+
     def getName(self):
         return 'foo'
     
@@ -34,12 +36,11 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = RadioWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('items'), [])
         self.assertEqual(self._widget.getValue('firstItem'), 0)
@@ -47,18 +48,19 @@
 
 
     def testRenderItem(self):
-        check_list = ('type="radio"', 'name="field_bar"', 'value="foo"',
+        check_list = ('type="radio"', 'name="field.bar"', 'value="foo"',
                       'Foo')
-        self._verifyResult(self._widget.renderItem('Foo', 'foo', 'bar', None),
-                           check_list)
+        self._verifyResult(
+            self._widget.renderItem('Foo', 'foo', 'field.bar', None),
+            check_list)
         check_list += ('checked="checked"',)
         self._verifyResult(
-            self._widget.renderSelectedItem('Foo', 'foo', 'bar', None),
+            self._widget.renderSelectedItem('Foo', 'foo', 'field.bar', None),
             check_list)
 
 
     def testRenderItems(self):
-        check_list = ('type="radio"', 'name="field_foo"', 'value="bar1"',
+        check_list = ('type="radio"', 'name="field.foo"', 'value="bar1"',
                       'Bar', 'value="foo1"', 'Foo', 'checked="checked"')
         self._verifyResult('\n'.join(self._widget.renderItems('bar1')),
                            check_list)
@@ -66,11 +68,11 @@
 
     def testRender(self):
         value = 'bar1'
-        check_list = ('type="radio"', 'name="field_foo"', 'value="bar1"',
+        check_list = ('type="radio"', 'name="field.foo"', 'value="bar1"',
                       'Bar', 'value="foo1"', 'Foo', 'checked="checked"')
         self._verifyResult(self._widget.render(value), check_list)
 
-        check_list = ('type="hidden"', 'name="field_foo"', 'value="bar1"')
+        check_list = ('type="hidden"', 'name="field.foo"', 'value="bar1"')
         self._verifyResult(self._widget.renderHidden(value), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextAreaWidget.py 1.2 => 1.2.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextAreaWidget.py:1.2	Wed Jul 17 12:54:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextAreaWidget.py	Mon Oct 28 11:51:24 2002
@@ -24,27 +24,25 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = TextAreaWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'text')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
-        # self.assertEqual(self._widget.getValue('default'), "")
         self.assertEqual(self._widget.getValue('width'), 80)
         self.assertEqual(self._widget.getValue('height'), 15)
 
     def testRender(self):
         value = "Foo Value"
-        check_list = ('rows="15"', 'cols="80"', 'name="field_foo"', 'textarea')
+        check_list = ('rows="15"', 'cols="80"', 'name="field.foo"', 'textarea')
         self._verifyResult(self._widget.render(value), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
         self._verifyResult(self._widget.render(value), check_list)
-        check_list = ('type="hidden"', 'name="field_foo"', 'value="Foo Value"')
+        check_list = ('type="hidden"', 'name="field.foo"', 'value="Foo Value"')
         self._verifyResult(self._widget.renderHidden(value), check_list)
 
 


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextWidget.py 1.2 => 1.2.6.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextWidget.py:1.2	Wed Jul 17 12:54:15 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testTextWidget.py	Mon Oct 28 11:51:24 2002
@@ -24,14 +24,13 @@
     
     def setUp(self):
         field = Field()
-        request = {'field_foo': 'Foo Value'}
+        request = {'field.foo': 'Foo Value'}
         self._widget = TextWidget(field, request)
 
     def testProperties(self):
         self.assertEqual(self._widget.getValue('tag'), 'input')
         self.assertEqual(self._widget.getValue('type'), 'text')
         self.assertEqual(self._widget.getValue('cssClass'), '')
-        self.assertEqual(self._widget.getValue('hidden'), 0)
         self.assertEqual(self._widget.getValue('extra'), '')
         self.assertEqual(self._widget.getValue('default'), '')
         self.assertEqual(self._widget.getValue('displayWidth'), 20)
@@ -39,7 +38,7 @@
 
     def testRender(self):
         value = 'Foo Value'
-        check_list = ('type="text"', 'name="field_foo"', 'value="Foo Value"',
+        check_list = ('type="text"', 'name="field.foo"', 'value="Foo Value"',
                       'size="20"')
         self._verifyResult(self._widget.render(value), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]