[Zope3-checkins] CVS: Zope3/src/zope/app/rdb - __init__.py:1.15

Stephan Richter srichter@cosmos.phy.tufts.edu
Wed, 11 Jun 2003 09:47:59 -0400


Update of /cvs-repository/Zope3/src/zope/app/rdb
In directory cvs.zope.org:/tmp/cvs-serv23479/rdb

Modified Files:
	__init__.py 
Log Message:
Fixed SQLScript:

- Removed doubled 'Cache' menu entry.

- I had to context-wrap connectionName (using ContextProperty), since
  ContextMethod(setConnectionName) did not work anymore.

- Caching also did not work correctly; in the __call__() method of SQLScript
  it used a lit '[]' as the marker for the default return object; for some
  reason this did not work. When I replaced the list with object(),
  everything worked just fine.

- Removed many bare excepts and therefore XXX comments

- Cleaned up the ISQLScript interface to remove old cruft from the time I did
  not feel comfortable with properties

- Fixed bug where it would not allow you to edit an SQL script unless a 'SQL
  Connections Service' was registered. 

- In the 'rdb' package, if we experience an exception during connect, we want
  to convert this exception to a DatabaseException, so that the higher-level
  machinery can catch it. Note that I had to leave the exception blank, since
  DBI implementations have their own Exception hierarchy.


=== Zope3/src/zope/app/rdb/__init__.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/rdb/__init__.py:1.14	Mon Jun  9 11:31:57 2003
+++ Zope3/src/zope/app/rdb/__init__.py	Wed Jun 11 09:47:59 2003
@@ -122,8 +122,16 @@
     def connect(self):
         'See IZopeDatabaseAdapter'
         if not self.isConnected():
-            self._v_connection = ZopeConnection(self._connection_factory(),
-                                                self)
+            try:
+                self._v_connection = ZopeConnection(
+                    self._connection_factory(), self)
+            # Note: I added the general Exception, since the DA can return
+            # implementation-specific errors. But we really want to catch all
+            # issues at this point, so that we can convert it to a
+            # DatabaseException. 
+            except Exception, error:
+                raise DatabaseException, str(error)
+
 
     def disconnect(self):
         'See IZopeDatabaseAdapter'