[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ ZPublisher.BaseRequest: The publisher would happily publish attributes

Stefan H. Holek stefan at epy.co.at
Sun Feb 19 07:14:40 EST 2006


Log message for revision 41694:
  ZPublisher.BaseRequest: The publisher would happily publish attributes
  of type 'bool' and 'complex'.
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/BaseRequest.py
  U   Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testBaseRequest.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===================================================================
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2006-02-19 12:05:45 UTC (rev 41693)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2006-02-19 12:14:40 UTC (rev 41694)
@@ -27,6 +27,9 @@
 
     Bugs Fixed
 
+      - ZPublisher.BaseRequest: The publisher would happily publish attributes
+        of type 'bool' and 'complex'.
+
       - Collector #1991: ZPublisher did not deal properly with a trailing
         %20 in the URL
 

Modified: Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/BaseRequest.py	2006-02-19 12:05:45 UTC (rev 41693)
+++ Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/BaseRequest.py	2006-02-19 12:14:40 UTC (rev 41694)
@@ -571,7 +571,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/Zope-2_8-branch/lib/python/ZPublisher/tests/testBaseRequest.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testBaseRequest.py	2006-02-19 12:05:45 UTC (rev 41693)
+++ Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testBaseRequest.py	2006-02-19 12:14:40 UTC (rev 41694)
@@ -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), ) )
 



More information about the Zope-Checkins mailing list