[Zope-CVS] CVS: Products/Ape/lib/apelib/sql - keygen.py:1.4 sqlbase.py:1.3 structure.py:1.3

Shane Hathaway shane@zope.com
Tue, 29 Apr 2003 18:12:21 -0400


Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv9561/sql

Modified Files:
	keygen.py sqlbase.py structure.py 
Log Message:
- Added IGatewayEvent, the base interface for ILoadEvent and
IStoreEvent.

- Filesystem gateways no longer refer directly to a connection.  They
get the connection from the event.  This is to permit replacing the
connection with a zip/tar file reader/writer or some other interesting
thing.

- Added checkConnection() to gateways for checking the connection
configuration early.

- Added ConfigurationError and changed some places that were raising
RuntimeError to raise ConfigurationError instead.

- Changed some calls to getKeyChain()[-1] to simply getKey()

- Updated module import style in some places

- Various other style improvements




=== Products/Ape/lib/apelib/sql/keygen.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/sql/keygen.py:1.3	Sat Apr 12 16:56:26 2003
+++ Products/Ape/lib/apelib/sql/keygen.py	Tue Apr 29 18:11:50 2003
@@ -18,6 +18,7 @@
 
 from apelib.core.interfaces import IKeychainGenerator, ISDEvent
 from apelib.core.schemas import FieldSchema
+from apelib.core.exceptions import ConfigurationError
 from sqlbase import SQLGatewayBase
 
 
@@ -33,22 +34,22 @@
 
     def setUpTables(self):
         conn = self.conn
-        insert = 0
+        first_time = 0
         try:
             rows = self.execute('check', 1)
-            if len(rows) != 1:
-                insert = 1
+            if len(rows) == 0:
+                first_time = 1
         except conn.error:
             conn.db.rollback()
             self.execute('create')
-            insert = 1
-        if insert and self.queries.get('insert'):
+            first_time = 1
+        if first_time and self.queries.get('insert'):
             self.execute('insert')
         conn.db.commit()
 
     def makeKeychain(self, event, name, stored):
         if not stored:
-            raise RuntimeError(
+            raise ConfigurationError(
                 'Keychains generated by SQLKeychain must be stored')
         if ISDEvent.isImplementedBy(event):
             # Request that the other side do the work (for ZEO)


=== Products/Ape/lib/apelib/sql/sqlbase.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/sql/sqlbase.py:1.2	Fri Apr 11 02:17:49 2003
+++ Products/Ape/lib/apelib/sql/sqlbase.py	Tue Apr 29 18:11:50 2003
@@ -35,6 +35,11 @@
     def getSchema(self):
         return self.schema
 
+    def checkConnection(self, event):
+        pass
+        # if not IDBAPIConnection.isImplementedBy(self.conn):
+        #     raise ConfigurationError
+
     def getColumnDefs(self):
         defs = self.column_defs
         if defs is None:


=== Products/Ape/lib/apelib/sql/structure.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/sql/structure.py:1.2	Fri Apr 11 02:17:49 2003
+++ Products/Ape/lib/apelib/sql/structure.py	Tue Apr 29 18:11:50 2003
@@ -103,7 +103,7 @@
         state.sort()
         for name, child_keychain in state:
             if child_keychain[:-1] != keychain1:
-                raise RuntimeError(
+                raise ValueError(
                     "SQLFolderItems cannot store cross-domain references")
             child_key = long(child_keychain[-1])
             kw = {'key': key, 'name': name, 'child_key': child_key}