[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - testzope2fs.py:1.3 testzope2sql.py:1.4
Shane Hathaway
shane@zope.com
Sun, 18 May 2003 00:17:01 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv23359/tests
Modified Files:
testzope2fs.py testzope2sql.py
Log Message:
Made the standard SQL gateways static rather than dependent on a
particular database connection. This is another step toward
simplifying the configuration of mappers. The change involved the
following:
- Refactored the query generator to generate only one query at a
time. Gateways no longer use it directly. Instead, they ask the
database connection to generate a query. The database connection
caches the generated query.
- Added a setUp method to gateways. The setUp method can check the
interface of the connection and/or create tables.
- Consolidated the set up procedure for SQL gateways into setUp().
- Added an argument to the execute() method of SQLGatewayBase so it
can find the connection.
- Arranged for ApeStorage to call gateway.setUp().
=== Products/Ape/lib/apelib/tests/testzope2fs.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/tests/testzope2fs.py:1.2 Tue Apr 29 18:11:51 2003
+++ Products/Ape/lib/apelib/tests/testzope2fs.py Sun May 18 00:16:30 2003
@@ -53,11 +53,10 @@
if not os.path.exists(tmpdir):
os.mkdir(tmpdir)
self.path = tmpdir
- dm, conns = self._createMapper(tmpdir)
- self.dm = dm
+ self.root_mapper, conns = self._createMapper(tmpdir)
assert len(conns) == 1
self.conn = conns['fs']
- resource = StaticResource(dm)
+ resource = StaticResource(self.root_mapper)
storage = ApeStorage(resource, conns)
self.storage = storage
db = ApeDB(storage, resource)
=== Products/Ape/lib/apelib/tests/testzope2sql.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/tests/testzope2sql.py:1.3 Tue Apr 29 18:11:51 2003
+++ Products/Ape/lib/apelib/tests/testzope2sql.py Sun May 18 00:16:30 2003
@@ -23,7 +23,7 @@
from apelib.zodb3.db import ApeDB
from apelib.zodb3.storage import ApeStorage
from apelib.zodb3.resource import StaticResource
-from apelib.zope2.sqlmapper import createConnectorMapper
+from apelib.zope2.sqlmapper import createAbstractMapper
from zope2testbase import Zope2TestBase
@@ -39,20 +39,15 @@
def setUp(self):
conn = self.getConnector()
- dm, conns, gws = createConnectorMapper(conn)
- self.dm = dm
- self.conns = conns
- self.gws = gws
- resource = StaticResource(dm)
- storage = ApeStorage(resource, conns)
+ self.root_mapper = createAbstractMapper()
+ resource = StaticResource(self.root_mapper)
+ self.conns = {'db': conn}
+ storage = ApeStorage(resource, self.conns, clear_all=1)
self.storage = storage
- db = ApeDB(storage, resource)
- self.db = db
+ self.db = ApeDB(storage, resource)
def clear(self):
- for gw in self.gws:
- if hasattr(gw, 'clear'):
- gw.clear()
+ self.storage.setUpGateways(clear_all=1)
for conn in self.conns.values():
conn.db.commit()