[Zope-CVS] CVS: Products/AdaptableStorage/gateway_sql - PsycopgConnection.py:1.7 SQLClassification.py:1.6 SQLFolderItems.py:1.6 SQLObjectData.py:1.3 SQLProperties.py:1.2 SQLUserList.py:1.4

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


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

Modified Files:
	PsycopgConnection.py SQLClassification.py SQLFolderItems.py 
	SQLObjectData.py SQLProperties.py SQLUserList.py 
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/gateway_sql/PsycopgConnection.py 1.6 => 1.7 ===
--- Products/AdaptableStorage/gateway_sql/PsycopgConnection.py:1.6	Tue Dec 31 16:47:45 2002
+++ Products/AdaptableStorage/gateway_sql/PsycopgConnection.py	Fri Jan 10 11:08:20 2003
@@ -16,8 +16,6 @@
 $Id$
 """
 
-import psycopg
-
 from mapper_public import ITPCConnection
 
 
@@ -28,9 +26,11 @@
     _final = 0
     db = None
     cursor = None
-    error = psycopg.DatabaseError
 
     def __init__(self, params='', prefix='zodb'):
+        import psycopg
+        self.error = psycopg.DatabaseError
+        self.Binary = psycopg.Binary
         self.params = params
         self.prefix = prefix
         self.connect_callbacks = []
@@ -42,6 +42,7 @@
         self.connect_callbacks.append(f)
 
     def connect(self):
+        import psycopg
         self.db = psycopg.connect(self.params)
         self.cursor = self.db.cursor()
         for f in self.connect_callbacks:
@@ -69,7 +70,7 @@
         return None
 
     def asBinary(self, data):
-        return psycopg.Binary(data)
+        return self.Binary(data)
 
     def begin(self):
         pass


=== Products/AdaptableStorage/gateway_sql/SQLClassification.py 1.5 => 1.6 ===
--- Products/AdaptableStorage/gateway_sql/SQLClassification.py:1.5	Thu Jan  9 09:33:59 2003
+++ Products/AdaptableStorage/gateway_sql/SQLClassification.py	Fri Jan 10 11:08:20 2003
@@ -29,12 +29,12 @@
 
     table_base_name = 'classification'
 
-    checkexist_sql = '''SELECT key FROM %(table)s LIMIT 1'''
+    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''
 
     create_sql = '''CREATE TABLE %(table)s (
     key int PRIMARY KEY,
     meta_type character varying(255),
-    class_name character varying(255)  
+    class_name character varying(255)
     )'''
 
     read_sql = '''SELECT meta_type, class_name from %(table)s


=== Products/AdaptableStorage/gateway_sql/SQLFolderItems.py 1.5 => 1.6 ===
--- Products/AdaptableStorage/gateway_sql/SQLFolderItems.py:1.5	Tue Dec 31 16:47:45 2002
+++ Products/AdaptableStorage/gateway_sql/SQLFolderItems.py	Fri Jan 10 11:08:20 2003
@@ -30,7 +30,7 @@
 
     table_base_name = 'folder_items'
 
-    checkexist_sql = '''SELECT key FROM %(table)s LIMIT 1'''
+    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''
 
     create_sql = '''CREATE TABLE %(table)s (
     key int,


=== Products/AdaptableStorage/gateway_sql/SQLObjectData.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/gateway_sql/SQLObjectData.py:1.2	Tue Dec 31 16:47:45 2002
+++ Products/AdaptableStorage/gateway_sql/SQLObjectData.py	Fri Jan 10 11:08:20 2003
@@ -29,7 +29,7 @@
 
     table_base_name = 'object_data'
 
-    checkexist_sql = '''SELECT key FROM %(table)s LIMIT 1'''
+    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''
 
     create_sql = '''CREATE TABLE %(table)s (
     key int PRIMARY KEY,


=== Products/AdaptableStorage/gateway_sql/SQLProperties.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/gateway_sql/SQLProperties.py:1.1	Fri Jan  3 17:04:19 2003
+++ Products/AdaptableStorage/gateway_sql/SQLProperties.py	Fri Jan 10 11:08:20 2003
@@ -32,7 +32,7 @@
 
     table_base_name = 'properties'
 
-    checkexist_sql = '''SELECT key FROM %(table)s LIMIT 1'''
+    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''
 
     create_sql = '''CREATE TABLE %(table)s (
     key int,


=== Products/AdaptableStorage/gateway_sql/SQLUserList.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/gateway_sql/SQLUserList.py:1.3	Thu Jan  9 09:33:59 2003
+++ Products/AdaptableStorage/gateway_sql/SQLUserList.py	Fri Jan 10 11:08:20 2003
@@ -33,7 +33,7 @@
 
     table_base_name = 'users'
 
-    checkexist_sql = '''SELECT key FROM %(table)s LIMIT 1'''
+    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''
 
     create_sql = '''CREATE TABLE %(table)s (
     key int,