[Zope3-checkins] SVN: Zope3/trunk/ Implemented issue 309.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sun Feb 27 17:45:03 EST 2005
Log message for revision 29326:
Implemented issue 309.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/doc/TODO.txt
U Zope3/trunk/src/zope/app/form/browser/meta.zcml
U Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-02-27 22:23:59 UTC (rev 29325)
+++ Zope3/trunk/doc/CHANGES.txt 2005-02-27 22:45:03 UTC (rev 29326)
@@ -10,6 +10,8 @@
New features
+ - Implemented issue 309: <schemadisplay> should support <widget>
+
- Developed a generic browser:form directive. It is pretty much the same
as the browser:editform directive, except that the data is not stored
on some context or adapted context but sent as a dictionary to special
Modified: Zope3/trunk/doc/TODO.txt
===================================================================
--- Zope3/trunk/doc/TODO.txt 2005-02-27 22:23:59 UTC (rev 29325)
+++ Zope3/trunk/doc/TODO.txt 2005-02-27 22:45:03 UTC (rev 29326)
@@ -15,8 +15,6 @@
- Issue 295: Sort out defaultView
-- Issue 309: <schemadisplay> should support <widget>
-
- Allow adapters (including views) to be registered for classes
(really implementation specifications of classes) as well as
interfaces. This has been done for page directives but needs to be
Modified: Zope3/trunk/src/zope/app/form/browser/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/meta.zcml 2005-02-27 22:23:59 UTC (rev 29325)
+++ Zope3/trunk/src/zope/app/form/browser/meta.zcml 2005-02-27 22:45:03 UTC (rev 29326)
@@ -92,9 +92,15 @@
<meta:complexDirective
name="schemadisplay"
schema=".metadirectives.ISchemaDisplayDirective"
- handler=".metaconfigure.SchemaDisplayDirective"
- />
+ handler=".metaconfigure.SchemaDisplayDirective">
+ <meta:subdirective
+ name="widget"
+ schema=".metadirectives.IWidgetSubdirective"
+ />
+
+ </meta:complexDirective>
+
</meta:directives>
</configure>
Modified: Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2005-02-27 22:23:59 UTC (rev 29325)
+++ Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2005-02-27 22:45:03 UTC (rev 29326)
@@ -373,6 +373,7 @@
default_template = 'display.pt'
def __call__(self):
+ self._processWidgets()
self._handle_menu()
self._context.action(
discriminator = self._discriminator(),
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2005-02-27 22:23:59 UTC (rev 29325)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2005-02-27 22:45:03 UTC (rev 29326)
@@ -169,6 +169,32 @@
# expect to fail as standard macros are not configured
self.assertRaises(TraversalError, v)
+ def testSchemaDisplay(self):
+ self.assertEqual(
+ zapi.queryMultiAdapter((ob, request), name='view.html'),
+ None)
+ xmlconfig(StringIO(template % ('''
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IField"
+ provides="zope.app.form.interfaces.IDisplayWidget"
+ factory="zope.app.form.browser.DisplayWidget"
+ permission="zope.Public"
+ />
+
+ <browser:schemadisplay
+ for="zope.app.form.browser.tests.test_directives.IC"
+ schema="zope.app.form.browser.tests.test_directives.Schema"
+ name="view.html"
+ label="View a ZPT page"
+ fields="text"
+ permission="zope.Public" />
+ ''')))
+
+ v = zapi.queryMultiAdapter((ob, request), name='view.html')
+ # expect to fail as standard macros are not configured
+ self.assertRaises(TraversalError, v)
+
def testAddFormWithWidget(self):
self.assertEqual(
zapi.queryMultiAdapter((ob, request), name='add.html'),
@@ -244,7 +270,43 @@
self.assertEqual(view.text_widget.extra, u'foo')
self.assertEqual(view.text_widget.displayWidth, 30)
+ def testSchemaDisplayWithWidget(self):
+ self.assertEqual(
+ zapi.queryMultiAdapter((ob, request), name='view.html'),
+ None)
+ xmlconfig(StringIO(template % ('''
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IField"
+ provides="zope.app.form.interfaces.IDisplayWidget"
+ factory="zope.app.form.browser.DisplayWidget"
+ permission="zope.Public"
+ />
+ <browser:schemadisplay
+ for="zope.app.form.browser.tests.test_directives.IC"
+ schema="zope.app.form.browser.tests.test_directives.Schema"
+ name="view.html"
+ label="View a ZPT page"
+ fields="text"
+ permission="zope.Public">
+
+ <browser:widget
+ field="text"
+ class="zope.app.form.browser.tests.test_directives.SomeWidget"
+ displayWidth="30"
+ extra="foo"
+ />
+ </browser:schemadisplay>
+ ''')))
+
+ view = zapi.queryMultiAdapter((ob, request), name='view.html')
+ self.assert_(hasattr(view, 'text_widget'))
+ self.assert_(isinstance(view.text_widget, SomeWidget))
+ self.assertEqual(view.text_widget.extra, u'foo')
+ self.assertEqual(view.text_widget.displayWidth, 30)
+
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
More information about the Zope3-Checkins
mailing list