Log message for revision 41696: Merged Zope 2.8 branch r41693:41694 into 2.9 branch. ZPublisher.BaseRequest: The publisher would happily publish attributes of type 'bool' and 'complex'.
Changed: U Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py U Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py =================================================================== --- Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py 2006-02-19 12:17:52 UTC (rev 41695) +++ Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py 2006-02-19 12:19:09 UTC (rev 41696) @@ -574,7 +574,8 @@ for name in ('NoneType', 'IntType', 'LongType', 'FloatType', 'StringType', 'BufferType', 'TupleType', 'ListType', 'DictType', 'XRangeType', 'SliceType', 'EllipsisType', 'UnicodeType', 'CodeType', - 'TracebackType', 'FrameType', 'DictProxyType'): + 'TracebackType', 'FrameType', 'DictProxyType', 'BooleanType', + 'ComplexType'): if hasattr(types, name): itypes[getattr(types, name)] = 0 Modified: Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py =================================================================== --- Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py 2006-02-19 12:17:52 UTC (rev 41695) +++ Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py 2006-02-19 12:19:09 UTC (rev 41696) @@ -16,7 +16,23 @@ """Attribute with docstring.""" return 'view content' + def noview(self): + # Attribute without docstring. + return 'unpublishable' + +class DummyObjectWithoutDocstring(Implicit): + "" + + def view(self): + """Attribute with docstring.""" + return 'view content' + + def noview(self): + # Attribute without docstring. + return 'unpublishable' + + class DummyObjectWithDefault(DummyObjectBasic): """Dummy class with docstring.""" @@ -68,6 +84,7 @@ return getattr(self, name) raise AttributeError, name + class TestBaseRequest(TestCase): def setUp(self): @@ -80,6 +97,11 @@ self.f1._setObject('objWithBD', DummyObjectWithBD() ) self.f1._setObject('objWithBBT', DummyObjectWithBBT() ) self.f1._setObject('objWithBDBBT', DummyObjectWithBDBBT() ) + self.f1._setObject('objWithoutDocstring', DummyObjectWithoutDocstring() ) + self.f1.simpleString = 'foo' + self.f1.simpleList = [] + self.f1.simpleBoolean = True + self.f1.simpleComplex = complex(1) def makeBaseRequest(self): response = HTTPResponse() @@ -183,7 +205,41 @@ self.assertEqual(r.URL, '/index_html') self.assertEqual(r.response.base, '') + def test_traverse_attribute_with_docstring(self): + r = self.makeBaseRequest() + r.traverse('folder/objBasic/view') + self.assertEqual(r.URL, '/folder/objBasic/view') + self.assertEqual(r.response.base, '') + def test_traverse_attribute_without_docstring(self): + from ZPublisher import NotFound + r = self.makeBaseRequest() + self.assertRaises(NotFound, r.traverse, 'folder/objBasic/noview') + + def test_traverse_class_without_docstring(self): + from ZPublisher import NotFound + r = self.makeBaseRequest() + self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring') + + def test_traverse_attribute_of_class_without_docstring(self): + from ZPublisher import NotFound + r = self.makeBaseRequest() + self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring/view') + + def test_traverse_attribute_and_class_without_docstring(self): + from ZPublisher import NotFound + r = self.makeBaseRequest() + self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring/noview') + + def test_traverse_simple_type(self): + from ZPublisher import NotFound + r = self.makeBaseRequest() + self.assertRaises(NotFound, r.traverse, 'folder/simpleString') + self.assertRaises(NotFound, r.traverse, 'folder/simpleList') + self.assertRaises(NotFound, r.traverse, 'folder/simpleBoolean') + self.assertRaises(NotFound, r.traverse, 'folder/simpleComplex') + + def test_suite(): return TestSuite( ( makeSuite(TestBaseRequest), ) ) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins