[Zope-CVS] CVS: Products/AdaptableStorage - Zope2SQL.py:1.10 doc.txt:1.5

Shane Hathaway shane@zope.com
Fri, 10 Jan 2003 11:08:51 -0500


Update of /cvs-repository/Products/AdaptableStorage
In directory cvs.zope.org:/tmp/cvs-serv14707

Modified Files:
	Zope2SQL.py doc.txt 
Log Message:
Moved toward SQL database independence.  Tried to port to Gadfly, but
Gadfly doesn't even support simple sequences, so it's not interesting
enough.  I'm checking in some of the changes anyway to simplify future
ports.

- Used a WHERE clause to limit the results of checking for table
existence rather than a LIMIT clause, since WHERE is more likely to be
supported everywhere.

- Changed the name of createMapper() to createPostgreSQLMapper().
Moved the creation of the connection to createPostgreSQLMapper(),
permitting reuse of createMapperPlus() by other databases.



=== Products/AdaptableStorage/Zope2SQL.py 1.9 => 1.10 ===
--- Products/AdaptableStorage/Zope2SQL.py:1.9	Tue Jan  7 00:07:30 2003
+++ Products/AdaptableStorage/Zope2SQL.py	Fri Jan 10 11:08:19 2003
@@ -18,17 +18,16 @@
 
 
 from mapper.public import ObjectGateway
-from gateway_sql.public import PsycopgConnection, SQLClassification, \
+from gateway_sql.public import SQLClassification, \
      SQLFolderItems, SQLItemId, SQLKeychainGenerator, SQLObjectData, \
      SQLProperties, SQLRemainder, SQLUserList
 
 from Zope2Mapper import createZope2Mapper
 
 
-def createMapperPlus(params='', table_prefix='zodb', volatile=1):
+def createSQLMapper(conn, volatile=1):
     """Object mapper factory, with extra return arg for testing purposes
     """
-    conn = PsycopgConnection(params, table_prefix)
     root_mapper = createZope2Mapper(0, 1)
     root_mapper.setVolatile(int(volatile))
     root_mapper.getClassifier().setGateway(SQLClassification(conn))
@@ -111,11 +110,13 @@
     return root_mapper, [conn], gws
 
 
-def createMapper(params='', table_prefix='zodb', volatile=1):
+def createPostgreSQLMapper(params='', table_prefix='zodb', volatile=1):
     """Object mapper factory.
 
     Usage in database configuration file:
     factory=Products.AdaptableStorage.Zope2SQL.createMapper
     """
-    return createMapperPlus(params, table_prefix, volatile)[:2]
+    from gateway_sql.public import PsycopgConnection
+    conn = PsycopgConnection(params, table_prefix)
+    return createSQLMapper(conn, volatile)[:2]
 


=== Products/AdaptableStorage/doc.txt 1.4 => 1.5 ===
--- Products/AdaptableStorage/doc.txt:1.4	Fri Jan  3 17:04:14 2003
+++ Products/AdaptableStorage/doc.txt	Fri Jan 10 11:08:19 2003
@@ -54,13 +54,13 @@
 
 Setting Up a SQL Mapping
 
-Install PostgreSQL and create a database.  Add the following
-dbtab.conf entries:
+Install PostgreSQL and psycopg and create a database.  Add the
+following dbtab.conf entries:
 
 
 [Storage: SQL]
 type=ASStorage
-factory=Products.AdaptableStorage.Zope2SQL.createMapper
+factory=Products.AdaptableStorage.Zope2SQL.createPostgreSQLMapper
 params=
 volatile=1