[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - sqlmapper.py:1.2
Shane Hathaway
shane@zope.com
Sat, 12 Apr 2003 16:56:27 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv28924/lib/apelib/zope2
Modified Files:
sqlmapper.py
Log Message:
Implemented support for MySQL 4.0, this time for real. The change required
further abstraction of the query generator. Supporting more databases
should now be straightforward.
=== Products/Ape/lib/apelib/zope2/sqlmapper.py 1.1 => 1.2 ===
--- Products/Ape/lib/apelib/zope2/sqlmapper.py:1.1 Wed Apr 9 23:09:58 2003
+++ Products/Ape/lib/apelib/zope2/sqlmapper.py Sat Apr 12 16:56:27 2003
@@ -18,10 +18,11 @@
from apelib.core import gateways
from apelib.sql import classification, keygen, properties, security, structure
+from apelib.sql import dbapi
from apelib.zope2 import basemapper
-def createSQLMapper(conn):
+def createConnectorMapper(conn):
"""Object mapper factory, with extra return arg for testing purposes
"""
root_mapper = basemapper.createZope2Mapper(0, 1)
@@ -130,14 +131,19 @@
return root_mapper, [conn], gws
-def createPostgreSQLMapper(params='', table_prefix='zodb', volatile=1):
+def createMapper(module_name, params='', kwparams='',
+ table_prefix='zodb', volatile=1):
"""Object mapper factory.
Usage in database configuration file:
- factory=apelib.zope2.fsmapper.createMapper
+ factory=apelib.zope2.sqlmapper.createDBAPIMapper
+ module_name=psycopg
+ params=
+ kwparams=
+ table_prefix=zodb
"""
# The "volatile" argument is ignored.
- from apelib.sql import pg
- conn = pg.PsycopgConnection(params, table_prefix)
- return createSQLMapper(conn)[:2]
+ conn = dbapi.DBAPIConnector(
+ module_name, params, kwparams, prefix=table_prefix)
+ return createConnectorMapper(conn)[:2]