[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_browserwidget.py:1.19.14.1 test_checkboxwidget.py:1.9.34.1 test_datetimewidget.py:1.2.34.1 test_datewidget.py:1.2.34.1 test_directives.py:1.3.2.1 test_editview.py:1.17.4.1 test_filewidget.py:1.7.34.1 test_floatwidget.py:1.2.34.1 test_intwidget.py:1.2.34.1 test_listwidget.py:1.8.34.1 test_multicheckboxwidget.py:1.8.34.1 test_multilistwidget.py:1.8.34.1 test_objectwidget.py:1.5.22.1 test_passwordwidget.py:1.8.34.1 test_radiowidget.py:1.10.34.1 test_sequencewidget.py:1.6.20.1 test_textareawidget.py:1.9.34.1 test_textwidget.py:1.7.34.1 test_vocabularywidget.py:1.28.14.1

Garrett Smith garrett at mojave-corp.com
Thu Feb 26 00:11:22 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv25181/src/zope/app/browser/form/tests

Modified Files:
      Tag: garrett-widgets2-branch
	test_browserwidget.py test_checkboxwidget.py 
	test_datetimewidget.py test_datewidget.py test_directives.py 
	test_editview.py test_filewidget.py test_floatwidget.py 
	test_intwidget.py test_listwidget.py 
	test_multicheckboxwidget.py test_multilistwidget.py 
	test_objectwidget.py test_passwordwidget.py 
	test_radiowidget.py test_sequencewidget.py 
	test_textareawidget.py test_textwidget.py 
	test_vocabularywidget.py 
Log Message:
Yet another branch for widgets refactoring (YABFWR).


=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.19 => 1.19.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.19	Tue Jan 20 15:15:26 2004
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py	Thu Feb 26 00:10:50 2004
@@ -68,10 +68,10 @@
         self.failIf(self._widget.hasInput())
 
     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('extra'), '')
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'text')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
 
     def testRender(self):
         value = 'Foo Value'


=== Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py 1.9 => 1.9.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py:1.9	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,25 +14,106 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import CheckBoxWidget
+from zope.publisher.browser import TestRequest
 from zope.schema import Bool
+from zope.interface.verify import verifyClass, verifyObject
 
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
 
 
 class CheckBoxWidgetTest(BrowserWidgetTest):
+    """Documents and tests thec checkbox widget.
+        
+        >>> verifyClass(IEditWidget, CheckBoxWidget)
+        True
+        
+    The rest of the this doctest was moved from widget.py to this test module
+    to keep widget.py free of detailed tests. XXX the tests below should be
+    more narrative to highlight the 'story' being told.
+
+    >>> field = Bool(__name__='foo', title=u'on')
+    >>> request = TestRequest(form={'field.foo.used': u'on',
+    ...                             'field.foo': u'on'})
+    >>> widget = CheckBoxWidget(field, request)
+    >>> widget.hasInput()
+    True
+    >>> widget.getInputValue()
+    True
+
+    >>> def normalize(s):
+    ...   return '\\n  '.join(s.split())
+
+    >>> print normalize( widget() )
+    <input
+      class="hiddenType"
+      id="field.foo.used"
+      name="field.foo.used"
+      type="hidden"
+      value=""
+      />
+      <input
+      class="checkboxType"
+      checked="checked"
+      id="field.foo"
+      name="field.foo"
+      type="checkbox"
+      />
+
+    >>> print normalize( widget.hidden() )
+    <input
+      class="hiddenType"
+      id="field.foo"
+      name="field.foo"
+      type="hidden"
+      value="on"
+      />
+
+    Calling setRenderedValue will change what gets output:
+
+    >>> widget.setRenderedValue(False)
+    >>> print normalize( widget() )
+    <input
+      class="hiddenType"
+      id="field.foo.used"
+      name="field.foo.used"
+      type="hidden"
+      value=""
+      />
+      <input
+      class="checkboxType"
+      id="field.foo"
+      name="field.foo"
+      type="checkbox"
+      />
+
+    When a checkbox is not 'checked', it's value is not
+    sent in the request, so we consider it 'False', which
+    means that 'required' for a boolean field doesn't make
+    much sense in the end.
+
+    >>> field = Bool(__name__='foo', title=u'on', required=True)
+    >>> request = TestRequest(form={'field.foo.used': u''})
+    >>> widget = CheckBoxWidget(field, request)
+    >>> widget.hasInput()
+    True
+    >>> widget.validate()
+    >>> widget.getInputValue()
+    False
+    """
 
     _FieldFactory = Bool
     _WidgetFactory = CheckBoxWidget
 
     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('extra'), '')
-        self.assertEqual(self._widget.getValue('default'), 0)
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'checkbox')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.default, 0)
 
     def testRender(self):
         value = 1
@@ -60,7 +141,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(CheckBoxWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(CheckBoxWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py 1.2 => 1.2.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py:1.2	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py	Thu Feb 26 00:10:50 2004
@@ -14,15 +14,23 @@
 """
 $Id$
 """
-from unittest import main, makeSuite
+import unittest, doctest
 from zope.app.datetimeutils import parseDatetimetz
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import DatetimeWidget
 from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass, verifyObject
+
 from zope.schema import Datetime
 
 
 class DatetimeWidgetTest(BrowserWidgetTest):
+    """Documents and tests the datetime widget.
+        
+        >>> verifyClass(IEditWidget, DatetimeWidget)
+        True
+    """
 
     _FieldFactory = Datetime
     _WidgetFactory = DatetimeWidget
@@ -47,8 +55,11 @@
 
 
 def test_suite():
-    return makeSuite(DatetimeWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(DatetimeWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
-    main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')
 


=== Zope3/src/zope/app/browser/form/tests/test_datewidget.py 1.2 => 1.2.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_datewidget.py:1.2	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datewidget.py	Thu Feb 26 00:10:50 2004
@@ -14,15 +14,21 @@
 """
 $Id$
 """
-from unittest import main, makeSuite
+import unittest, doctest
 from zope.app.datetimeutils import parseDatetimetz
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import DateWidget
 from zope.app.interfaces.form import ConversionError, WidgetInputError
 from zope.schema import Date
-
+from zope.interface.verify import verifyClass, verifyObject
 
 class DateWidgetTest(BrowserWidgetTest):
+    """Documents and tests the date widget.
+
+        >>> verifyClass(IEditWidget, DateWidget)
+        True
+    """
 
     _FieldFactory = Date
     _WidgetFactory = DateWidget
@@ -48,8 +54,11 @@
 
 
 def test_suite():
-    return makeSuite(DateWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(DateWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
-    main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')
 


=== Zope3/src/zope/app/browser/form/tests/test_directives.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_directives.py:1.3	Wed Feb 25 18:02:17 2004
+++ Zope3/src/zope/app/browser/form/tests/test_directives.py	Thu Feb 26 00:10:50 2004
@@ -1,4 +1,4 @@
-###########################################################IC#############
+#############################################################################
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
@@ -66,12 +66,11 @@
 ob = Ob()
 
 
-
-
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         super(Test, self).setUp()
+        XMLConfig('meta.zcml', zope.app.component)()
         XMLConfig('meta.zcml', zope.app.browser.form)()
         XMLConfig('meta.zcml', zope.app.publisher.browser)()
 
@@ -88,24 +87,23 @@
     def testEditForm(self):
         self.assertEqual(queryView(ob, 'test', request),
                          None)
-        xmlconfig(StringIO(template % (
-            """
-              <browser:page
-                  permission="zope.Public"
-                  allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
-                  for="zope.schema.interfaces.ITextLine"
-                  name="edit"
-                  class="zope.app.browser.form.widget.TextWidget"
-                  />
-              <browser:editform
-                  for="zope.app.browser.form.tests.test_directives.IC"
-                  schema="zope.app.browser.form.tests.test_directives.Schema"
-                  name="edit.html"
-                  label="Edit a ZPT page"
-                  fields="text"
-                  permission="zope.Public" />
-            """
-            )))
+        xmlconfig(StringIO(template % ("""
+          <view
+              type="zope.publisher.interfaces.browser.IBrowserRequest"
+              for="zope.schema.interfaces.ITextLine"
+              provides="zope.app.interfaces.form.IEditWidget"
+              factory="zope.app.browser.form.widget.TextWidget"
+              permission="zope.Public"
+              />
+
+          <browser:editform
+              for="zope.app.browser.form.tests.test_directives.IC"
+              schema="zope.app.browser.form.tests.test_directives.Schema"
+              name="edit.html"
+              label="Edit a ZPT page"
+              fields="text"
+              permission="zope.Public" />
+            """)))
 
         v = queryView(ob, 'edit.html', request)
         # expect component lookup as standard macros are not configured
@@ -115,28 +113,26 @@
     def testEditFormWithMenu(self):
         self.assertEqual(queryView(ob, 'test', request),
                          None)
-        xmlconfig(StringIO(template % (
-            """
-              <browser:menu id="test_menu" title="Test menu" usage="objectview"/>
-              <browser:page
-                  permission="zope.Public"
-                  allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
-                  for="zope.schema.interfaces.ITextLine"
-                  name="edit"
-                  class="zope.app.browser.form.widget.TextWidget"
-                  />
-              <browser:editform
-                  for="zope.app.browser.form.tests.test_directives.IC"
-                  schema="zope.app.browser.form.tests.test_directives.Schema"
-                  name="edit.html"
-                  label="Edit a ZPT page"
-                  fields="text"
-                  permission="zope.Public"
-                  menu="test_menu"
-                  title="Test View"
-                  />
-            """
-            )))
+        xmlconfig(StringIO(template % ("""
+          <browser:menu id="test_menu" title="Test menu" usage="objectview"/>
+          <view
+              type="zope.publisher.interfaces.browser.IBrowserRequest"
+              for="zope.schema.interfaces.ITextLine"
+              provides="zope.app.interfaces.form.IEditWidget"
+              factory="zope.app.browser.form.widget.TextWidget"
+              permission="zope.Public"
+              />
+          <browser:editform
+              for="zope.app.browser.form.tests.test_directives.IC"
+              schema="zope.app.browser.form.tests.test_directives.Schema"
+              name="edit.html"
+              label="Edit a ZPT page"
+              fields="text"
+              permission="zope.Public"
+              menu="test_menu"
+              title="Test View"
+              />
+            """)))
 
         v = queryView(ob, 'edit.html', request)
         self.assertEqual(v.usage, 'objectview')
@@ -146,26 +142,24 @@
     def testEditFormWithUsage(self):
         self.assertEqual(queryView(ob, 'test', request),
                          None)
-        xmlconfig(StringIO(template % (
-            """
-              <browser:page
-                  permission="zope.Public"
-                  allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
-                  for="zope.schema.interfaces.ITextLine"
-                  name="edit"
-                  class="zope.app.browser.form.widget.TextWidget"
-                  />
-              <browser:editform
-                  for="zope.app.browser.form.tests.test_directives.IC"
-                  schema="zope.app.browser.form.tests.test_directives.Schema"
-                  name="edit.html"
-                  label="Edit a ZPT page"
-                  fields="text"
-                  permission="zope.Public"
-                  usage="objectview"
-                  />
-            """
-            )))
+        xmlconfig(StringIO(template % ("""
+          <view
+              type="zope.publisher.interfaces.browser.IBrowserRequest"
+              for="zope.schema.interfaces.ITextLine"
+              provides="zope.app.interfaces.form.IEditWidget"
+              factory="zope.app.browser.form.widget.TextWidget"
+              permission="zope.Public"
+              />
+          <browser:editform
+              for="zope.app.browser.form.tests.test_directives.IC"
+              schema="zope.app.browser.form.tests.test_directives.Schema"
+              name="edit.html"
+              label="Edit a ZPT page"
+              fields="text"
+              permission="zope.Public"
+              usage="objectview"
+              />
+            """)))
 
         v = queryView(ob, 'edit.html', request)
         self.assertEqual(v.usage, 'objectview')
@@ -176,29 +170,27 @@
     def testEditFormWithMenuAndUsage(self):
         self.assertEqual(queryView(ob, 'test', request),
                          None)
-        xmlconfig(StringIO(template % (
-            """
-              <browser:menu id="test_menu" title="Test menu" usage="overridden"/>
-              <browser:page
-                  permission="zope.Public"
-                  allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
-                  for="zope.schema.interfaces.ITextLine"
-                  name="edit"
-                  class="zope.app.browser.form.widget.TextWidget"
-                  />
-              <browser:editform
-                  for="zope.app.browser.form.tests.test_directives.IC"
-                  schema="zope.app.browser.form.tests.test_directives.Schema"
-                  name="edit.html"
-                  label="Edit a ZPT page"
-                  fields="text"
-                  permission="zope.Public"
-                  menu="test_menu"
-                  title="Test View"
-                  usage="objectview"        
-                  />
-            """
-            )))
+        xmlconfig(StringIO(template % ("""
+          <browser:menu id="test_menu" title="Test menu" usage="overridden"/>
+          <view
+              type="zope.publisher.interfaces.browser.IBrowserRequest"
+              for="zope.schema.interfaces.ITextLine"
+              provides="zope.app.interfaces.form.IEditWidget"
+              factory="zope.app.browser.form.widget.TextWidget"
+              permission="zope.Public"
+              />
+          <browser:editform
+              for="zope.app.browser.form.tests.test_directives.IC"
+              schema="zope.app.browser.form.tests.test_directives.Schema"
+              name="edit.html"
+              label="Edit a ZPT page"
+              fields="text"
+              permission="zope.Public"
+              menu="test_menu"
+              title="Test View"
+              usage="objectview"        
+              />
+            """)))
 
         v = queryView(ob, 'edit.html', request)
         self.assertEqual(v.usage, 'objectview')


=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.17 => 1.17.4.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.17	Wed Feb 25 08:22:09 2004
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py	Thu Feb 26 00:10:50 2004
@@ -27,6 +27,7 @@
 from zope.app.browser.form.widget import TextWidget
 from zope.app.browser.form.submit import Update
 from zope.component.exceptions import ComponentLookupError
+from zope.app.interfaces.form import IEditWidget
 
 class I(Interface):
     foo = TextLine(title=u"Foo")
@@ -100,8 +101,7 @@
 
     def setUp(self):
         super(Test, self).setUp()
-        ztapi.browserView(ITextLine, 'edit', TextWidget)
-        ztapi.setDefaultViewName(ITextLine, "edit")
+        ztapi.browserViewProviding(ITextLine, TextWidget, IEditWidget)
         ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
 
     def test_setPrefix_and_widgets(self):


=== Zope3/src/zope/app/browser/form/tests/test_filewidget.py 1.7 => 1.7.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_filewidget.py:1.7	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_filewidget.py	Thu Feb 26 00:10:50 2004
@@ -14,14 +14,22 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
 from StringIO import StringIO
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import FileWidget
 
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
 
+from zope.interface.verify import verifyClass, verifyObject
+
 class FileWidgetTest(BrowserWidgetTest):
+    """Documents and tests the file widget.
+    
+        >>> verifyClass(IEditWidget, FileWidget)
+        True
+    """
 
     _WidgetFactory = FileWidget
 
@@ -33,13 +41,13 @@
         self._widget.request.form['field.foo'] = file
 
     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('extra'), '')
-        self.assertEqual(self._widget.getValue('default'), '')
-        self.assertEqual(self._widget.getValue('displayWidth'), 20)
-        self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'file')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.default, '')
+        self.assertEqual(self._widget.displayWidth, 20)
+        self.assertEqual(self._widget.displayMaxWidth, '')
 
     def testRender(self):
         value = 'Foo Value'
@@ -57,7 +65,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(FileWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(FileWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_floatwidget.py 1.2 => 1.2.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_floatwidget.py:1.2	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_floatwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,14 +14,22 @@
 """
 $Id$
 """
-from unittest import main, makeSuite
+import unittest, doctest
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import FloatWidget
 from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass, verifyObject
+
 from zope.schema import Float
 
 
 class FloatWidgetTest(BrowserWidgetTest):
+    """Documents and tests the float widget.
+        
+        >>> verifyClass(IEditWidget, FloatWidget)
+        True
+    """
 
     _FieldFactory = Float
     _WidgetFactory = FloatWidget
@@ -45,7 +53,10 @@
 
 
 def test_suite():
-    return makeSuite(FloatWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(FloatWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
-    main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_intwidget.py 1.2 => 1.2.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_intwidget.py:1.2	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_intwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,14 +14,23 @@
 """
 $Id$
 """
+import unittest, doctest
 from unittest import main, makeSuite
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import IntWidget
 from zope.app.interfaces.form import ConversionError, WidgetInputError
+from zope.interface.verify import verifyClass, verifyObject
+
 from zope.schema import Int
 
 
 class IntWidgetTest(BrowserWidgetTest):
+    """Documents and tests the int widget.
+        
+        >>> verifyClass(IEditWidget, IntWidget)
+        True
+    """
 
     _FieldFactory = Int
     _WidgetFactory = IntWidget
@@ -45,7 +54,10 @@
 
 
 def test_suite():
-    return makeSuite(IntWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(IntWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
-    main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_listwidget.py 1.8 => 1.8.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_listwidget.py:1.8	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_listwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,12 +14,19 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import ListWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass, verifyObject
 
 class ListWidgetTest(BrowserWidgetTest):
+    """Documents and tests the list widget.
+        
+        >>> verifyClass(IEditWidget, ListWidget)
+        True
+    """
 
     def setUp(self):
         BrowserWidgetTest.setUp(self)
@@ -28,10 +35,10 @@
     _WidgetFactory = ListWidget
 
     def testProperties(self):
-        self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('extra'), '')
-        self.assertEqual(self._widget.getValue('firstItem'), 0)
-        self.assertEqual(self._widget.getValue('size'), 5)
+        self.assertEqual(self._widget.cssClass, "")
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.firstItem, 0)
+        self.assertEqual(self._widget.size, 5)
 
 
     def testRenderItem(self):
@@ -71,7 +78,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(ListWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(ListWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py 1.8 => 1.8.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py:1.8	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,12 +14,19 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import MultiCheckBoxWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass, verifyObject
 
 class MultiCheckBoxWidgetTest(BrowserWidgetTest):
+    """Documents and tests the multi checkbox widget.
+        
+        >>> verifyClass(IEditWidget, MultiCheckBoxWidget)
+        True
+    """
 
     _WidgetFactory = MultiCheckBoxWidget
 
@@ -28,9 +35,9 @@
         self._widget.context.allowed_values = (u'foo', u'bar')
 
     def testProperties(self):
-        self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('extra'), '')
-        self.assertEqual(self._widget.getValue('orientation'), 'vertical')
+        self.assertEqual(self._widget.cssClass, "")
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.orientation, 'vertical')
 
 
     def testRenderItem(self):
@@ -71,7 +78,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(MultiCheckBoxWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(MultiCheckBoxWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py 1.8 => 1.8.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py:1.8	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,12 +14,19 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import MultiListWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass, verifyObject
 
 class MultiListWidgetTest(BrowserWidgetTest):
+    """Documents and tests the multi-list widget.
+        
+        >>> verifyClass(IEditWidget, MultiListWidget)
+        True
+    """
 
     _WidgetFactory = MultiListWidget
 
@@ -28,9 +35,9 @@
         self._widget.context.allowed_values = (u'foo', u'bar')
 
     def testProperties(self):
-        self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('extra'), '')
-        self.assertEqual(self._widget.getValue('size'), 5)
+        self.assertEqual(self._widget.cssClass, "")
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.size, 5)
 
 
     def testRenderItem(self):
@@ -70,7 +77,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(MultiListWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(MultiListWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_objectwidget.py 1.5 => 1.5.22.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_objectwidget.py:1.5	Fri Nov 21 12:11:56 2003
+++ Zope3/src/zope/app/browser/form/tests/test_objectwidget.py	Thu Feb 26 00:10:50 2004
@@ -15,14 +15,17 @@
 $Id$
 """
 
-import unittest
+import unittest, doctest
 
 from zope.app.tests import ztapi
 from zope.interface import Interface, implements
 from zope.schema.interfaces import ITextLine
 from zope.publisher.browser import TestRequest
 from zope.schema import Object, TextLine
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import TextWidget, ObjectWidget
+from zope.interface.verify import verifyClass, verifyObject
+from zope.app.interfaces.form import IEditWidget
 
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
 
@@ -33,13 +36,19 @@
     implements(ITestContact)
 
 class ObjectWidgetTest(BrowserWidgetTest):
+    """Documents and tests the object widget.
+        
+        >>> verifyClass(IEditWidget, ObjectWidget)
+        True
+    """
+
     _FieldFactory = Object
     def _WidgetFactory(self, context, request, **kw):
         kw.update({'factory': TestContact})
         return ObjectWidget(context, request, **kw)
 
     def setUpContent(self, desc=u''):
-        ztapi.browserView(ITextLine, 'edit', TextWidget)
+        ztapi.browserViewProviding(ITextLine, TextWidget, IEditWidget)
 
         class ITestContent(Interface):
             foo = self._FieldFactory(
@@ -67,7 +76,7 @@
     def setUp(self):
         BrowserWidgetTest.setUp(self)
         self.field = Object(ITestContact, __name__=u'foo')
-        ztapi.browserView(ITextLine, 'edit', [TextWidget])
+        ztapi.browserViewProviding(ITextLine, TextWidget, IEditWidget)
 
     def test_applyChanges(self):
         self.request.form['field.foo.name'] = u'Foo Name'
@@ -124,7 +133,10 @@
         self.verifyResult(widget(), check_list)
 
 def test_suite():
-    return unittest.makeSuite(ObjectWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(ObjectWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py 1.8 => 1.8.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py:1.8	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,24 +14,30 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import PasswordWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
-
+from zope.interface.verify import verifyClass, verifyObject
 
 class PasswordWidgetTest(BrowserWidgetTest):
+    """Documents and tests the password widget.
+
+        >>> verifyClass(IEditWidget, PasswordWidget)
+        True
+    """
 
     _WidgetFactory = PasswordWidget
 
     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('extra'), '')
-        self.assertEqual(self._widget.getValue('default'), '')
-        self.assertEqual(self._widget.getValue('displayWidth'), 20)
-        self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'password')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.default, '')
+        self.assertEqual(self._widget.displayWidth, 20)
+        self.assertEqual(self._widget.displayMaxWidth, '')
 
     def testRender(self):
         value = 'Foo Value'
@@ -44,7 +50,10 @@
         self.assertRaises(NotImplementedError, self._widget.hidden)
 
 def test_suite():
-    return unittest.makeSuite(PasswordWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(PasswordWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_radiowidget.py 1.10 => 1.10.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_radiowidget.py:1.10	Sat Aug 16 13:23:37 2003
+++ Zope3/src/zope/app/browser/form/tests/test_radiowidget.py	Thu Feb 26 00:10:50 2004
@@ -14,12 +14,19 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import RadioWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
+from zope.interface.verify import verifyClass, verifyObject
 
 class RadioWidgetTest(BrowserWidgetTest):
+    """Documents and tests the radio widget.
+        
+        >>> verifyClass(IEditWidget, RadioWidget)
+        True
+    """
 
     _WidgetFactory = RadioWidget
 
@@ -28,10 +35,10 @@
         self._widget.context.allowed_values = (u'foo', u'bar')
 
     def testProperties(self):
-        self.assertEqual(self._widget.getValue('cssClass'), "")
-        self.assertEqual(self._widget.getValue('extra'), '')
-        self.assertEqual(self._widget.getValue('firstItem'), 0)
-        self.assertEqual(self._widget.getValue('orientation'), 'vertical')
+        self.assertEqual(self._widget.cssClass, "")
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.firstItem, 0)
+        self.assertEqual(self._widget.orientation, 'vertical')
 
 
     def testRenderItem(self):
@@ -117,7 +124,10 @@
                               '</div>' % (id, label, id, value))
 
 def test_suite():
-    return unittest.makeSuite(RadioWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(RadioWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py 1.6 => 1.6.20.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py:1.6	Mon Jan  5 06:24:58 2004
+++ Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py	Thu Feb 26 00:10:50 2004
@@ -15,22 +15,33 @@
 $Id$
 """
 
-import unittest
+import unittest, doctest
 
 from zope.app.tests import ztapi
 from zope.app.browser.form.widget import TextWidget
 from zope.schema.interfaces import ITextLine, ValidationError
 from zope.publisher.browser import TestRequest
 from zope.schema import Tuple, List, TextLine
-from zope.app.browser.form.widget import TupleSequenceWidget, \
-    ListSequenceWidget
-
+from zope.app.interfaces.form import IEditWidget
+from zope.app.browser.form.widget import TupleSequenceWidget
+from zope.app.browser.form.widget import ListSequenceWidget
+from zope.interface.verify import verifyClass, verifyObject
 
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
 
 class SequenceWidgetTest(BrowserWidgetTest):
+    """Documents and tests the tuple and list (sequence) widgets.
+    
+        >>> verifyClass(IEditWidget, TupleSequenceWidget)
+        True
+        >>> verifyClass(IEditWidget, ListSequenceWidget)
+        True
+    """
+
     def _FieldFactory(self, **kw):
-        kw.update({'__name__': u'foo', 'value_type': TextLine(__name__=u'bar')})
+        kw.update({
+            '__name__': u'foo', 
+            'value_type': TextLine(__name__=u'bar')})
         return Tuple(**kw)
     _WidgetFactory = TupleSequenceWidget
 
@@ -39,9 +50,10 @@
 
     def setUp(self):
         BrowserWidgetTest.setUp(self)
-        self.field = Tuple(__name__=u'foo',
+        self.field = Tuple(
+            __name__=u'foo',
             value_type=TextLine(__name__=u'bar'))
-        ztapi.browserView(ITextLine, 'edit', TextWidget)
+        ztapi.browserViewProviding(ITextLine, TextWidget, IEditWidget)
 
     def test_haveNoData(self):
         self.failIf(self._widget.hasInput())
@@ -51,7 +63,9 @@
         self.failUnless(self._widget.hasInput())
 
     def test_list(self):
-        self.field = List(__name__=u'foo', value_type=TextLine(__name__=u'bar'))
+        self.field = List(
+            __name__=u'foo',
+            value_type=TextLine(__name__=u'bar'))
         request = TestRequest()
         widget = ListSequenceWidget(self.field, request)
         self.failIf(widget.hasInput())
@@ -167,7 +181,10 @@
         self.verifyResult(s, check_list, inorder=True)
 
 def test_suite():
-    return unittest.makeSuite(SequenceWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(SequenceWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_textareawidget.py 1.9 => 1.9.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_textareawidget.py:1.9	Sat Aug 16 13:23:37 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textareawidget.py	Thu Feb 26 00:10:50 2004
@@ -14,23 +14,29 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import TextAreaWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
-
+from zope.interface.verify import verifyClass, verifyObject
 
 class TextAreaWidgetTest(BrowserWidgetTest):
+    """Documents and tests the text area widget.
+
+        >>> verifyClass(IEditWidget, TextAreaWidget)
+        True
+    """
 
     _WidgetFactory = TextAreaWidget
 
     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('extra'), '')
-        self.assertEqual(self._widget.getValue('width'), 60)
-        self.assertEqual(self._widget.getValue('height'), 15)
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'text')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.width, 60)
+        self.assertEqual(self._widget.height, 15)
 
     def testRender(self):
         value = "Foo Value"
@@ -47,7 +53,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(TextAreaWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(TextAreaWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_textwidget.py 1.7 => 1.7.34.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_textwidget.py:1.7	Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textwidget.py	Thu Feb 26 00:10:50 2004
@@ -14,24 +14,32 @@
 """
 $Id$
 """
-import unittest
+import unittest, doctest
 
+from zope.interface.verify import verifyClass, verifyObject
+from zope.schema import TextLine
+
+from zope.app.interfaces.form import IEditWidget
 from zope.app.browser.form.widget import TextWidget
 from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
 
-
 class TextWidgetTest(BrowserWidgetTest):
+    """Documents and tests the text widget.
+
+        >>> verifyClass(IEditWidget, TextWidget)
+        True
+    """
 
     _WidgetFactory = TextWidget
 
     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('extra'), '')
-        self.assertEqual(self._widget.getValue('default'), '')
-        self.assertEqual(self._widget.getValue('displayWidth'), 20)
-        self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
+        self.assertEqual(self._widget.tag, 'input')
+        self.assertEqual(self._widget.inputType, 'text')
+        self.assertEqual(self._widget.cssClass, '')
+        self.assertEqual(self._widget.extra, '')
+        self.assertEqual(self._widget.default, '')
+        self.assertEqual(self._widget.displayWidth, 20)
+        self.assertEqual(self._widget.displayMaxWidth, '')
 
     def testRender(self):
         value = 'Foo Value'
@@ -45,10 +53,11 @@
         self._widget.extra = 'style="color: red"'
         self.verifyResult(self._widget.hidden(), check_list)
 
-
-
 def test_suite():
-    return unittest.makeSuite(TextWidgetTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(TextWidgetTest),
+        doctest.DocTestSuite(),
+        ))
 
 if __name__=='__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.28 => 1.28.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.28	Thu Feb  5 09:55:47 2004
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py	Thu Feb 26 00:10:50 2004
@@ -16,13 +16,14 @@
 
 import unittest
 
+from zope.app import zapi
 from zope.app.tests import ztapi
 from zope.app.browser.form import vocabularywidget
 from zope.app.browser.form.tests import support
+from zope.app.interfaces.form import IEditWidget, IDisplayWidget
 from zope.app.interfaces.browser.form import IBrowserWidget
 from zope.app.interfaces.browser.form import IVocabularyQueryView
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component import getView
 from zope.interface.declarations import implements
 from zope.publisher.browser import TestRequest
 
@@ -32,7 +33,6 @@
 from zope.schema.interfaces import IVocabularyTokenized
 from zope.schema import vocabulary
 
-
 class ISampleVocabulary(IVocabularyTokenized, IVocabulary):
     """Specialized interface so we can hook views onto a vocabulary."""
 
@@ -47,7 +47,9 @@
 
     This is not intended to be a useful widget.
     """
-    implements(IBrowserWidget)
+    implements(IBrowserWidget,
+               vocabularywidget.IVocabularyDisplayWidget,
+               vocabularywidget.IVocabularyListDisplayWidget)
 
     def __call__(self):
         return "foo"
@@ -150,35 +152,36 @@
         # This is equivalent to the default configuration for
         # vocabulary field view registration from configure.zcml.
         # Single-selection views only.
-        ztapi.browserView(
+        ztapi.browserViewProviding(
             IVocabularyField,
-            "display",
-            vocabularywidget.VocabularyFieldDisplayWidget)
-        ztapi.browserView(
+            vocabularywidget.VocabularyFieldDisplayWidget,
+            IDisplayWidget)
+        ztapi.browserViewProviding(
             IVocabularyField,
-            "edit",
-            vocabularywidget.VocabularyFieldEditWidget)
+            vocabularywidget.VocabularyFieldEditWidget,
+            IEditWidget)
         # Register the "basic" widgets:
-        ztapi.browserView(
+        ztapi.browserViewProviding(
             IVocabularyTokenized,
-            "field-display-widget",
-            vocabularywidget.VocabularyDisplayWidget)
-        ztapi.browserView(
+            vocabularywidget.VocabularyDisplayWidget,
+            vocabularywidget.IVocabularyDisplayWidget)
+        ztapi.browserViewProviding(
             IVocabularyTokenized,
-            "field-edit-widget",
             # XXX indirect through a derived class to allow
             # testing of multiple concrete widgets
-            self.singleSelectionEditWidget)
-        ztapi.browserView(
+            self.singleSelectionEditWidget,
+            vocabularywidget.IVocabularyEditWidget)
+        ztapi.browserViewProviding(
             IIterableVocabularyQuery,
-            "widget-query-helper",
-            vocabularywidget.IterableVocabularyQueryView)
+            vocabularywidget.IterableVocabularyQueryView,
+            vocabularywidget.IWidgetQueryHelper)
         # The following widget registration supports the specific
         # sample vocabulary we're using, used to demonstrate how to
         # override widget selection based on vocabulary:
-        ztapi.browserView(ISampleVocabulary,
-                    "field-display-widget",
-                                        SampleDisplayWidget)
+        ztapi.browserViewProviding(
+            ISampleVocabulary,
+            SampleDisplayWidget,
+            vocabularywidget.IVocabularyDisplayWidget)
 
 
 class MultiSelectionViews:
@@ -187,33 +190,34 @@
         # This is equivalent to the default configuration for
         # vocabulary field view registration from configure.zcml.
         # Multi-selection views only.
-        ztapi.browserView(
+        ztapi.browserViewProviding(
             IVocabularyListField,
-            "display",
-            vocabularywidget.VocabularyListFieldDisplayWidget)
-        ztapi.browserView(
+            vocabularywidget.VocabularyListFieldDisplayWidget,
+            IDisplayWidget)
+        ztapi.browserViewProviding(
             IVocabularyListField,
-            "edit",
-            vocabularywidget.VocabularyListFieldEditWidget)
+            vocabularywidget.VocabularyListFieldEditWidget,
+            IEditWidget)
         # Bind widgets to the vocabulary fields:
-        ztapi.browserView(
+        ztapi.browserViewProviding(
             IVocabularyTokenized,
-            "field-display-list-widget",
-            vocabularywidget.VocabularyListDisplayWidget)
-        ztapi.browserView(
+            vocabularywidget.VocabularyListDisplayWidget,
+            vocabularywidget.IVocabularyListDisplayWidget)
+        ztapi.browserViewProviding(
             IVocabularyTokenized,
-            "field-edit-list-widget",
-            vocabularywidget.VocabularyMultiEditWidget)
-        ztapi.browserView(
+            vocabularywidget.VocabularyMultiEditWidget,
+            vocabularywidget.IVocabularyMultiEditWidget)
+        ztapi.browserViewProviding(
             IIterableVocabularyQuery,
-            "widget-query-list-helper",
-            vocabularywidget.IterableVocabularyQueryMultiView)
+            vocabularywidget.IterableVocabularyQueryMultiView,
+            vocabularywidget.IWidgetQueryHelper)
         # The following widget registration supports the specific
         # sample vocabulary we're using, used to demonstrate how to
         # override widget selection based on vocabulary:
-        ztapi.browserView(ISampleVocabulary,
-                    "field-display-list-widget",
-                                        SampleDisplayWidget)
+        ztapi.browserViewProviding(
+            ISampleVocabulary,
+            SampleDisplayWidget,
+            vocabularywidget.IVocabularyListDisplayWidget)
 
 
 class SelectionTestBase(VocabularyWidgetTestBase):
@@ -221,7 +225,7 @@
 
     def test_vocabulary_specialization(self):
         bound = self.makeField(SampleVocabulary.fromValues(["frobnication"]))
-        w = getView(bound, "display", self.makeRequest())
+        w = zapi.getViewProviding(bound, IDisplayWidget, self.makeRequest())
         self.assertEqual(w(), "foo")
 
 
@@ -236,19 +240,19 @@
 
     def test_display(self):
         bound = self.makeField()
-        w = getView(bound, "display", self.makeRequest())
+        w = zapi.getViewProviding(bound, IDisplayWidget, self.makeRequest())
         w.setRenderedValue(bound.context.f)
         self.assertEqual(w(), "splat")
 
     def test_display_with_form_value(self):
         bound = self.makeField()
         request = self.makeRequest('field.f=foobar')
-        w = getView(bound, "display", request)
+        w = zapi.getViewProviding(bound, IDisplayWidget, request)
         self.assert_(w.hasInput())
         self.assertEqual(w(), "foobar")
 
     def setup_edit(self, bound):
-        w = getView(bound, "edit", self.makeRequest())
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest())
         w.setRenderedValue(bound.context.f)
         self.assert_(not w.hasInput())
         return w
@@ -307,7 +311,7 @@
     def test_edit_with_form_value(self):
         bound = self.makeField()
         request = self.makeRequest('field.f=foobar')
-        w = getView(bound, "edit", request)
+        w = zapi.getViewProviding(bound, IEditWidget, request)
         self.assert_(w.hasInput())
         self.assertEqual(w.getInputValue(), "foobar")
         self.assert_(isinstance(w, vocabularywidget.VocabularyEditWidget))
@@ -318,7 +322,7 @@
         # report hasInput() properly.
         bound = self.makeField()
         bound.context.f = "splat"
-        w = getView(bound, "edit", self.makeRequest(
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest(
             'field.f-empty-marker='))
         self.assert_(w.hasInput())
         self.assertEqual(w.getInputValue(), None) # XXX might be []...
@@ -338,7 +342,7 @@
     def test_edit_with_form_value(self):
         bound = self.makeField()
         request = self.makeRequest('field.f=foobar')
-        w = getView(bound, "edit", request)
+        w = zapi.getViewProviding(bound, IEditWidget, request)
         self.assert_(w.hasInput())
         self.assertEqual(w.getInputValue(), "foobar")
         self.assert_(isinstance(w, vocabularywidget.RadioWidget))
@@ -418,13 +422,13 @@
     def test_display_without_value(self):
         bound = self.makeField()
         del bound.context.f
-        w = getView(bound, "display", self.makeRequest())
+        w = zapi.getViewProviding(bound, IDisplayWidget, self.makeRequest())
         self.assert_(not w.hasInput())
         self.assertEqual(w(), "")
 
     def test_display_with_value(self):
         bound = self.makeField(value=["foobar", "frob"])
-        w = getView(bound, "display", self.makeRequest())
+        w = zapi.getViewProviding(bound, IDisplayWidget, self.makeRequest())
         w.setRenderedValue(bound.context.f)
         self.assert_(not w.hasInput())
         self.verifyResult(w(), [
@@ -446,7 +450,7 @@
     def test_display_with_form_data(self):
         bound = self.makeField(value=["foobar", "frob"])
         request = self.makeRequest('field.f:list=splat')
-        w = getView(bound, "display", request)
+        w = zapi.getViewProviding(bound, IDisplayWidget, request)
         self.assert_(w.hasInput())
         s = w()
         self.verifyResult(s, [
@@ -463,7 +467,7 @@
 
     def test_edit(self):
         bound = self.makeField()
-        w = getView(bound, "edit", self.makeRequest())
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest())
         self.assert_(not w.hasInput())
         self.verifyResult(w(), [
             'id="field.f"',
@@ -495,7 +499,7 @@
     def test_edit_with_form_value(self):
         bound = self.makeField()
         request = self.makeRequest('field.f:list=foobar&field.f:list=splat')
-        w = getView(bound, "edit", request)
+        w = zapi.getViewProviding(bound, IEditWidget, request)
         self.assert_(w.hasInput())
         L = w.getInputValue()
         L.sort()
@@ -516,7 +520,7 @@
     def test_get_query_helper(self):
         bound = self.makeField()
         request = self.makeRequest()
-        w = getView(bound, "edit", request)
+        w = zapi.getViewProviding(bound, IEditWidget, request)
         self.assert_(isinstance(w.query, MyVocabularyQuery))
         self.assert_(w.queryview.widget is w)
         self.assertEqual(w.queryview.name, w.name + "-query")
@@ -524,7 +528,7 @@
 
     def test_query_input_section(self):
         bound = self.makeField()
-        w = getView(bound, "edit", self.makeRequest())
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest())
         w.setRenderedValue(bound.context.f)
         checks = [
             "this-is-query-input",
@@ -534,7 +538,7 @@
 
     def test_query_output_section_without_results(self):
         bound = self.makeField()
-        w = getView(bound, "edit", self.makeRequest())
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest())
         w.setRenderedValue(bound.context.f)
         checks = [
             "query-results-go-here",
@@ -544,7 +548,7 @@
 
     def test_query_output_section_with_results(self):
         bound = self.makeField()
-        w = getView(bound, "edit", self.makeRequest("field.f-query=foo"))
+        w = zapi.getViewProviding(bound, IEditWidget, self.makeRequest("field.f-query=foo"))
         w.setRenderedValue(bound.context.f)
         checks = [
             "query-results-go-here",
@@ -564,9 +568,10 @@
 
     def registerViews(self):
         SingleSelectionViews.registerViews(self)
-        ztapi.browserView(IMyVocabularyQuery,
-                          "widget-query-helper",
-                          MyQueryViewSingle)
+        ztapi.browserViewProviding(
+            IMyVocabularyQuery,
+            MyQueryViewSingle,
+            vocabularywidget.IWidgetQueryHelper)
 
 
 class MultiSelectionQuerySupportTests(MultiSelectionViews,
@@ -579,9 +584,10 @@
 
     def registerViews(self):
         MultiSelectionViews.registerViews(self)
-        ztapi.browserView(IMyVocabularyQuery,
-                          "widget-query-list-helper",
-                          MyQueryViewMulti)
+        ztapi.browserViewProviding(
+            IMyVocabularyQuery,
+            MyQueryViewMulti,
+            vocabularywidget.IWidgetQueryListHelper)
 
 
 def test_suite():




More information about the Zope3-Checkins mailing list