Update of /usr/cvs/Public/pygresql/module
In directory druid.net:/tmp/cvs-serv28109/module

Modified Files:
        TEST_PyGreSQL_dbapi20.py pgdb.py 
Log Message:
Added function for getting or setting the decimal type to be used by PyGreSQL.
To see the diffs for this commit:
   
http://www.druid.net/pygresql/viewcvs.cgi/cvs/pygresql/module/TEST_PyGreSQL_dbapi20.py.diff?r1=1.12&r2=1.13

Index: TEST_PyGreSQL_dbapi20.py
===================================================================
RCS file: /usr/cvs/Public/pygresql/module/TEST_PyGreSQL_dbapi20.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TEST_PyGreSQL_dbapi20.py    23 Nov 2008 11:45:54 -0000      1.12
+++ TEST_PyGreSQL_dbapi20.py    23 Nov 2008 12:19:21 -0000      1.13
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# $Id: TEST_PyGreSQL_dbapi20.py,v 1.12 2008/11/23 11:45:54 cito Exp $
+# $Id: TEST_PyGreSQL_dbapi20.py,v 1.13 2008/11/23 12:19:21 cito Exp $
 
 import dbapi20
 import unittest
@@ -55,7 +55,7 @@
         self.assertEqual(curs.fetchone(), {'a': 1, 'b': 2})
 
     def test_fetch_2_rows(self):
-        Decimal = pgdb.Decimal
+        Decimal = pgdb.decimal_type()
         values = ['test', 'test', True, 5, 6L, 5.7,
             Decimal('234.234234'), Decimal('75.45'),
             '2008-10-20 15:25:35', 7897234L]
@@ -92,6 +92,19 @@
     def test_setoutputsize(self):
         pass # not implemented
 
+    def test_connection_errors(self):
+        con = self._connect()
+        self.assertEqual(con.Error, pgdb.Error)
+        self.assertEqual(con.Warning, pgdb.Warning)
+        self.assertEqual(con.InterfaceError, pgdb.InterfaceError)
+        self.assertEqual(con.DatabaseError, pgdb.DatabaseError)
+        self.assertEqual(con.InternalError, pgdb.InternalError)
+        self.assertEqual(con.OperationalError, pgdb.OperationalError)
+        self.assertEqual(con.ProgrammingError, pgdb.ProgrammingError)
+        self.assertEqual(con.IntegrityError, pgdb.IntegrityError)
+        self.assertEqual(con.DataError, pgdb.DataError)
+        self.assertEqual(con.NotSupportedError, pgdb.NotSupportedError)
+
     def test_cursor_connection(self):
         con = self._connect()
         curs = con.cursor()

   
http://www.druid.net/pygresql/viewcvs.cgi/cvs/pygresql/module/pgdb.py.diff?r1=1.51&r2=1.52

Index: pgdb.py
===================================================================
RCS file: /usr/cvs/Public/pygresql/module/pgdb.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- pgdb.py     23 Nov 2008 11:45:54 -0000      1.51
+++ pgdb.py     23 Nov 2008 12:19:21 -0000      1.52
@@ -4,7 +4,7 @@
 #
 # Written by D'Arcy J.M. Cain
 #
-# $Id: pgdb.py,v 1.51 2008/11/23 11:45:54 cito Exp $
+# $Id: pgdb.py,v 1.52 2008/11/23 12:19:21 cito Exp $
 #
 
 """pgdb - DB-API 2.0 compliant module for PygreSQL.
@@ -91,6 +91,15 @@
 
 ### Internal Types Handling
 
+def decimal_type(decimal_type=None):
+    """Get or set global type to be used for decimal values."""
+    global Decimal
+    if decimal_type is not None:
+        Decimal = decimal_type
+        set_decimal(decimal_type)
+    return Decimal
+
+
 def _cast_bool(value):
     return value[:1] in ['t', 'T']
 
@@ -344,14 +353,15 @@
     """Connection Object."""
 
     # expose the exceptions as attributes on the connection object
-    Warning = Warning
     Error = Error
+    Warning = Warning
     InterfaceError = InterfaceError
     DatabaseError = DatabaseError
-    OperationalError = OperationalError
-    IntegrityError = IntegrityError
     InternalError = InternalError
+    OperationalError = OperationalError
     ProgrammingError = ProgrammingError
+    IntegrityError = IntegrityError
+    DataError = DataError
     NotSupportedError = NotSupportedError
 
     def __init__(self, cnx):

_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to