[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7980 - in trunk/gnue-common/src/datasources: . drivers/DBSIG2
From: |
reinhard |
Subject: |
[gnue] r7980 - in trunk/gnue-common/src/datasources: . drivers/DBSIG2 |
Date: |
Wed, 28 Sep 2005 12:35:40 -0500 (CDT) |
Author: reinhard
Date: 2005-09-24 00:50:21 -0500 (Sat, 24 Sep 2005)
New Revision: 7980
Modified:
trunk/gnue-common/src/datasources/Exceptions.py
trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
Log:
Show statement and parameters as detail of ConnectionError exceptions.
Modified: trunk/gnue-common/src/datasources/Exceptions.py
===================================================================
--- trunk/gnue-common/src/datasources/Exceptions.py 2005-09-23 13:39:47 UTC
(rev 7979)
+++ trunk/gnue-common/src/datasources/Exceptions.py 2005-09-24 05:50:21 UTC
(rev 7980)
@@ -25,6 +25,7 @@
"""
from gnue.common.apps import errors
+from gnue.common.utils import TextUtils
# =============================================================================
@@ -228,4 +229,8 @@
Raised whenever the database backend cannot execute what GNUe tells to do.
"""
- pass
+ def __init__ (self, message, statement, parameters):
+ errors.AdminError.__init__ (self, message)
+ self.detail = TextUtils.lineWrap (statement, 80)
+ for (key, value) in parameters.items ():
+ self.detail += "\n %s: %s" % (key, repr (value))
Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
2005-09-23 13:39:47 UTC (rev 7979)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
2005-09-24 05:50:21 UTC (rev 7980)
@@ -131,7 +131,7 @@
parameters [key] = value
statement = "INSERT INTO %s (%s) VALUES (%s)" % (table, ', '.join (fields),
', '.join (values))
- return self.__execute (statement, parameters)
+ return self.sql0 (statement, parameters)
# ---------------------------------------------------------------------------
@@ -144,14 +144,14 @@
parameters [key] = value
statement = "UPDATE %s SET %s WHERE %s" % (table, ', '.join (updates),
where)
- self.__execute (statement, parameters)
+ self.sql0 (statement, parameters)
# ---------------------------------------------------------------------------
def _delete_ (self, table, oldfields):
(where, parameters) = self.__where (oldfields)
statement = 'DELETE FROM %s WHERE %s' % (table, where)
- self.__execute (statement, parameters)
+ self.sql0 (statement, parameters)
# ---------------------------------------------------------------------------
@@ -159,10 +159,7 @@
(where, parameters) = self.__where (oldfields)
statement = "SELECT %s FROM %s WHERE %s" % (', '.join (fields), table,
where)
- try:
- rows = self.sql (statement, parameters)
- except self._driver.DatabaseError:
- raise Exceptions.ConnectionError, errors.getException () [2]
+ rows = self.sql (statement, parameters)
if len (rows):
row = rows [0]
result = {}
@@ -182,7 +179,8 @@
try:
self._native.commit ()
except self._driver.DatabaseError:
- raise Exceptions.ConnectionError, errors.getException () [2]
+ raise Exceptions.ConnectionError, (errors.getException () [2], 'COMMIT',
+ None)
# ---------------------------------------------------------------------------
@@ -219,18 +217,6 @@
# ---------------------------------------------------------------------------
- # Execute an insert, update, or delete statement
- # ---------------------------------------------------------------------------
-
- def __execute (self, statement, parameters):
-
- try:
- return self.sql0 (statement, parameters)
- except self._driver.DatabaseError:
- raise Exceptions.ConnectionError, errors.getException () [2]
-
-
- # ---------------------------------------------------------------------------
# Execute the given SQL statement and return the result matrix
# ---------------------------------------------------------------------------
@@ -370,7 +356,8 @@
cursor.execute (s)
except:
cursor.close ()
- raise
+ raise Exceptions.ConnectionError, (errors.getException () [2], statement,
+ parameters)
return cursor
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7980 - in trunk/gnue-common/src/datasources: . drivers/DBSIG2,
reinhard <=