[z3-checkins] r5870 - in z3/Five/trunk: . tests
tests/products/FiveTest
andy_a at codespeak.net
andy_a at codespeak.net
Wed Aug 4 16:48:42 MEST 2004
Author: andy_a
Date: Wed Aug 4 16:48:41 2004
New Revision: 5870
Modified:
z3/Five/trunk/browserconfigure.py
z3/Five/trunk/tests/products/FiveTest/browser.py
z3/Five/trunk/tests/products/FiveTest/configure.zcml
z3/Five/trunk/tests/test_five.py
Log:
New-style classes are now ignored in browser:page. Added some tests to verify that they are ignored and that the widgets from zope.app.form.browser can be registered and used. Now FiveFormDemo is working, too.
Modified: z3/Five/trunk/browserconfigure.py
==============================================================================
--- z3/Five/trunk/browserconfigure.py (original)
+++ z3/Five/trunk/browserconfigure.py Wed Aug 4 16:48:41 2004
@@ -68,6 +68,10 @@
raise ConfigurationError("No such file", template)
if class_:
+ # new-style classes do not work with Five. As we want to import
+ # packages from z3 directly, we ignore new-style classes for now.
+ if type(class_) == type:
+ return
if attribute != '__call__':
if not hasattr(class_, attribute):
raise ConfigurationError(
Modified: z3/Five/trunk/tests/products/FiveTest/browser.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/browser.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/browser.py Wed Aug 4 16:48:41 2004
@@ -35,6 +35,21 @@
object = CallableNoDocstring()
+class NewStyleClass(object):
+ """
+ This is a testclass to verify that new style classes are ignored
+ in browser:page
+ """
+
+ def __init__(self, context, request):
+ """Docstring"""
+ self.context = context
+ self.request = request
+
+ def method(self):
+ """Docstring"""
+ return
+
class StandardMacros(BaseMacros):
macro_pages = ('bird_macros', 'dog_macros')
Modified: z3/Five/trunk/tests/products/FiveTest/configure.zcml
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/configure.zcml (original)
+++ z3/Five/trunk/tests/products/FiveTest/configure.zcml Wed Aug 4 16:48:41 2004
@@ -283,4 +283,19 @@
factory=".classes.OriginalAdapter"
/>
+ <!-- browser:page directives with new style classes are ignored -->
+
+ <browser:page
+ for=".interfaces.ISimpleContent"
+ class=".browser.NewStyleClass"
+ name="invalid_page"
+ attribute="method"
+ permission="zope2.Public"
+ />
+
+ <!-- as new style classes are ignored, zope.app.form.browser
+ can be imported -->
+
+ <include package="zope.app.form.browser"/>
+
</configure>
Modified: z3/Five/trunk/tests/test_five.py
==============================================================================
--- z3/Five/trunk/tests/test_five.py (original)
+++ z3/Five/trunk/tests/test_five.py Wed Aug 4 16:48:41 2004
@@ -14,7 +14,10 @@
ZopeTestCase.installProduct('FiveTest')
ZopeTestCase.installProduct('Five')
+import zope
from zope.component import getViewProviding
+from zope.schema import Choice, TextLine
+from zope.app.form.interfaces import IInputWidget
from zope.app.traversing.browser.interfaces import IAbsoluteURL
from Products.FiveTest.classes import Adaptable, Origin
@@ -221,6 +224,21 @@
view = self.folder.unrestrictedTraverse(base % macro)
self.failUnless(view)
+ def test_ignore_new_style_class(self):
+ view = self.folder.unrestrictedTraverse('testoid/@@invalid_page')
+ self.assertEquals(view, None)
+
+ def test_get_widgets_for_schema_fields(self):
+ salutation = Choice(title=u'Salutation', values=("Mr.", "Mrs.", "Captain", "Don"))
+ contactname = TextLine(title=u'Name')
+ request = FakeRequest()
+ salutation = salutation.bind(request)
+ contactname = contactname.bind(request)
+ view1 = getViewProviding(contactname, IInputWidget, request)
+ self.assertEquals(view1.__class__, zope.app.form.browser.textwidgets.TextWidget)
+ view2 = getViewProviding(salutation, IInputWidget, request)
+ self.assertEquals(view2.__class__, zope.app.form.browser.itemswidgets.DropdownWidget)
+
def test_existing_call(self):
view = self.folder.unrestrictedTraverse('testcall')
self.assertEquals("Default __call__ called", view())
@@ -282,6 +300,7 @@
response = self.publish('/test_folder_1_/testoid', basic='manager:r00t')
self.assertEquals("The eagle has landed", response.getBody())
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(FiveTestCase))
More information about the z3-checkins
mailing list