Log message for revision 108851:
  Added test case for dictionary-style attribute access (like record['foo'], 
and fixed __setitem__ functionality which was broken.

Changed:
  U   
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/Results.py
  U   
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/tests/test_results.py

-=-
Modified: 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/Results.py
===================================================================
--- 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/Results.py    
    2010-02-06 18:59:43 UTC (rev 108850)
+++ 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/Results.py    
    2010-02-07 01:03:55 UTC (rev 108851)
@@ -126,9 +126,9 @@
                 if uppercase != name:
                     cls.register_alias(name, uppercase)
 
-        def __get_item__(self, key):
+        def __getitem__(self, key):
             try:
-                return namedtuple_cls[key]
+                return namedtuple_cls.__getitem__(self,key)
             except TypeError:
                 return self.get_item_by_name(key)
 

Modified: 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/tests/test_results.py
===================================================================
--- 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/tests/test_results.py
     2010-02-06 18:59:43 UTC (rev 108850)
+++ 
Zope/branches/zeomega-2.11-memory-fixes/lib/python/Shared/DC/ZRDB/tests/test_results.py
     2010-02-07 01:03:55 UTC (rev 108851)
@@ -70,6 +70,19 @@
         self.assertEqual(row.STRING, 'string2')
         self.assertEqual(row.INT, 2)
 
+    def test_getitem_by_name(self):
+        ob = self._makeOne((self.columns, self.data))
+        row = ob[0]
+        self.assertEqual(row['string'], 'string1')
+        self.assertEqual(row['int'], 1)
+        self.assertEqual(row['STRING'], 'string1')
+        self.assertEqual(row['INT'], 1)
+        row = ob[1]
+        self.assertEqual(row['string'], 'string2')
+        self.assertEqual(row['int'], 2)
+        self.assertEqual(row['STRING'], 'string2')
+        self.assertEqual(row['INT'], 2)
+
     def test_suppliedbrain(self):
         ob = self._makeOne((self.columns, self.data), brains=Brain)
         row = ob[0]

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to