[Zope-Checkins] SVN: Zope/branches/2.10/ Collector #2287: form ':record' objects did not implement enough of the mapping interface.

Tres Seaver tseaver at palladion.com
Mon Sep 24 17:06:49 EDT 2007


Log message for revision 79912:
  Collector #2287: form ':record' objects did not implement enough of the mapping interface.
  

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt	2007-09-24 21:04:22 UTC (rev 79911)
+++ Zope/branches/2.10/doc/CHANGES.txt	2007-09-24 21:06:48 UTC (rev 79912)
@@ -8,6 +8,9 @@
 
     Bugs fixed
 
+      - Collector #2287: form ':record' objects did not implement enough of
+        the mapping interface.
+
       - Collector #2352: fix in OFS.Traversable
 
       - Collector #2346: username logging in FCGI crashed the server

Modified: Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py	2007-09-24 21:04:22 UTC (rev 79911)
+++ Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py	2007-09-24 21:06:48 UTC (rev 79912)
@@ -1529,7 +1529,7 @@
     _guarded_writes = 1
 
     def __getattr__(self, key, default=None):
-        if key in ('get', 'keys', 'items', 'values', 'copy', 'has_key'):
+        if key in ('get', 'keys', 'items', 'values', 'copy', 'has_key', '__contains__', '__iter__', '__len__'):
             return getattr(self.__dict__, key)
         raise AttributeError, key
 

Modified: Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py	2007-09-24 21:04:22 UTC (rev 79911)
+++ Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py	2007-09-24 21:06:48 UTC (rev 79912)
@@ -77,7 +77,29 @@
         d = eval( r )
         self.assertEqual( d, record.__dict__ )
 
+    def test_contains(self):
+        from ZPublisher.HTTPRequest import record
+        record = record()
+        record.a = 1
+        self.assertTrue('a' in record)
 
+    def test_iter(self):
+        from ZPublisher.HTTPRequest import record
+        record = record()
+        record.a = 1
+        record.b = 2
+        record.c = 3
+        for k in record:
+            self.assertTrue(k in ('a','b','c'))
+
+    def test_len(self):
+        from ZPublisher.HTTPRequest import record
+        record = record()
+        record.a = 1
+        record.b = 2
+        record.c = 3
+        self.assertEqual(len(record), 3)
+
 class ProcessInputsTests(unittest.TestCase):
     def _getHTTPRequest(self, env):
         from ZPublisher.HTTPRequest import HTTPRequest



More information about the Zope-Checkins mailing list