[Zope3-checkins] SVN: Zope3/trunk/ Fixed a Gadfly DB Adapter bug that was reported, fixed and tested by

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Jan 3 13:58:37 EST 2006


Log message for revision 41109:
  Fixed a Gadfly DB Adapter bug that was reported, fixed and tested by
  Tadashi Matsumoto.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/rdb/gadflyda.py
  A   Zope3/trunk/src/zope/app/rdb/tests/test_gadflyphantom.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-01-03 18:44:17 UTC (rev 41108)
+++ Zope3/trunk/doc/CHANGES.txt	2006-01-03 18:58:37 UTC (rev 41109)
@@ -12,6 +12,11 @@
 
     Bug Fixes
 
+      - Fixed storage bug reported, fixed and tested by Zhiyun (Simon) Hang.
+
+      - Fixed a Gadfly DB Adapter bug that was reported, fixed and tested by
+        Tadashi Matsumoto.
+
       - zope.app.content_types is now the package zope.app.contenttypes
         (code backported from Zope 2)
 
@@ -22,6 +27,12 @@
       - Fixed issue 497: HTTP DELETE now returns 405 Method Not Allowed
         when the container cannot be adapted to IWriteDirectory.
 
+    Much thanks to everyone who contributed to this release:
+
+      Jim Fulton, Marius Gedminas, Brian Sutherland, Stephan Richter, Dimitry
+      Vasiliev, Tim Peters, Zachery Bir, Gary Poster, Egon Frerich, Zhiyun
+      (Simon) Hang, Tadashi Matsumoto
+
   ------------------------------------------------------------------
 
   Zope 3.2.0b2

Modified: Zope3/trunk/src/zope/app/rdb/gadflyda.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadflyda.py	2006-01-03 18:44:17 UTC (rev 41108)
+++ Zope3/trunk/src/zope/app/rdb/gadflyda.py	2006-01-03 18:58:37 UTC (rev 41109)
@@ -50,7 +50,9 @@
     """A Gadfly adapter for Zope3"""
 
     # The registerable object needs to have a container
-    __name__ = __parent__ = None 
+    __name__ = __parent__ = None
+    _v_connection = None
+    paramstyle = 'qmark'
 
     def _connection_factory(self):
         """Create a Gadfly DBI connection based on the DSN.

Added: Zope3/trunk/src/zope/app/rdb/tests/test_gadflyphantom.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/tests/test_gadflyphantom.py	2006-01-03 18:44:17 UTC (rev 41108)
+++ Zope3/trunk/src/zope/app/rdb/tests/test_gadflyphantom.py	2006-01-03 18:58:37 UTC (rev 41109)
@@ -0,0 +1,101 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Gadfly Database adapter phatom tests
+
+$Id: $
+"""
+__docformat__ = 'restructuredtext'
+import os, shutil
+import tempfile, threading
+from unittest import TestCase, TestSuite, main, makeSuite
+
+from zope.app.rdb.gadflyda import GadflyAdapter, setGadflyRoot
+
+class GadflyTestBase(TestCase):
+
+    def setUp(self):
+        TestCase.setUp(self)
+        self.tempdir = None
+
+    def tearDown(self):
+        TestCase.tearDown(self)
+        if self.tempdir:
+            shutil.rmtree(self.tempdir)
+        setGadflyRoot()
+
+    def getGadflyRoot(self):
+        if not self.tempdir:
+            self.tempdir = tempfile.mkdtemp('gadfly')
+        setGadflyRoot(self.tempdir)
+        return self.tempdir
+
+    def _create(self, *args):
+        return GadflyAdapter(*args)
+
+def exec_sql(adapter, sql, args, fetch=False):
+
+    conn = adapter()
+    cur =conn.cursor()
+    cur.execute(sql, args)
+    rows = []
+    if fetch:
+        rows = cur.fetchall()
+    conn.commit()
+    return rows
+
+class TestPhantom(GadflyTestBase):
+
+    def setUp(self):
+        GadflyTestBase.setUp(self)
+        dir = self.getGadflyRoot()
+        os.mkdir(os.path.join(dir, "demo"))
+        self.adapter = self._create("dbi://demo")
+        conn = self.adapter()
+        cur = conn.cursor()
+        cur.execute("create table t1 (name varchar)")
+        conn.commit()
+
+    def test_Phantom(self):
+
+        adapter = self.adapter
+        insert = "insert into t1 values (?)"
+        select = "select name from t1"
+        delete = "delete from t1"
+
+        count = 0
+        for name in ('a', 'b', 'c'):
+            t = threading.Thread(target=exec_sql,
+                                 args=(adapter, insert, (name,)))
+            t.start()
+            t.join()
+            rows = exec_sql(adapter, select, args=(), fetch=True)
+            count += 1
+            self.assertEqual(len(rows), count)
+
+        exec_sql(adapter, delete, args=())
+        t = threading.Thread(target=exec_sql,
+                             args=(adapter, delete, ()))
+        t.start()
+        t.join()
+        rows = exec_sql(adapter, select, args=(), fetch=True)
+        self.assertEqual(len(rows), 0)
+
+def test_suite():
+    return TestSuite((
+        makeSuite(TestPhantom),
+        ))
+
+if __name__=='__main__':
+
+    main(defaultTest='test_suite')


Property changes on: Zope3/trunk/src/zope/app/rdb/tests/test_gadflyphantom.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list