Log message for revision 41700:
  Merged Zope 2.8 branch r41693:41694 into the trunk.
  
  ZPublisher.BaseRequest: The publisher would happily publish attributes
  of type 'bool' and 'complex'.
  

Changed:
  U   Zope/trunk/lib/python/ZPublisher/BaseRequest.py
  U   Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py

-=-
Modified: Zope/trunk/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/BaseRequest.py     2006-02-19 12:35:15 UTC 
(rev 41699)
+++ Zope/trunk/lib/python/ZPublisher/BaseRequest.py     2006-02-19 12:39:36 UTC 
(rev 41700)
@@ -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/trunk/lib/python/ZPublisher/tests/testBaseRequest.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py   2006-02-19 
12:35:15 UTC (rev 41699)
+++ Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py   2006-02-19 
12:39:36 UTC (rev 41700)
@@ -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

Reply via email to