[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5232 - in trunk/gnue-common/src/datasources: . drivers/postgresql/psyco
From: |
jan |
Subject: |
r5232 - in trunk/gnue-common/src/datasources: . drivers/postgresql/psycopg drivers/postgresql/pygresql |
Date: |
Fri, 5 Mar 2004 13:58:56 -0600 (CST) |
Author: jan
Date: 2004-03-05 13:58:55 -0600 (Fri, 05 Mar 2004)
New Revision: 5232
Added:
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
Modified:
trunk/gnue-common/src/datasources/GConnections.py
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
Log:
fix error in case of double loading of some special dbdrivers (like interbase
f.e.)
defer loading for all postgresql drivers
Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py 2004-03-05 18:06:40 UTC
(rev 5231)
+++ trunk/gnue-common/src/datasources/GConnections.py 2004-03-05 19:58:55 UTC
(rev 5232)
@@ -251,7 +251,16 @@
"Please contact a gnue developer.") % driver
raise Exceptions.ProviderNotSupportedError, tmsg
- conn = dbdriver.Connection(self, connection_name, parameters)
+ try:
+ conn = dbdriver.Connection(self, connection_name, parameters)
+ except TypeError:
+ # Check for the case that a "Connection" is passed instead of a
+ # "Connection" class. This is the case, when the procedure for deferal
+ # of the loading of the connection object is overwriten by the
"connection"
+ # module. i.e. there is a Connection.py file
+ # TODO: remove this extra check by cleaning up the whole loading
procedure
+ conn = dbdriver.Connection.Connection(self, connection_name, parameters)
+
self._openConnections[connection_name] = conn
if login:
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
2004-03-05 18:06:40 UTC (rev 5231)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
2004-03-05 19:58:55 UTC (rev 5232)
@@ -28,15 +28,6 @@
# NOTES:
#
-__all__ = ('Connection')
-
-from gnue.common.datasources.drivers.postgresql import Base
-import psycopg
-
-class Connection(Base.Connection):
- _pg_driver = psycopg
-
-
__description__ = _("Psycopg Data Driver for PostgreSQL")
__driverurl__ = "http://????"
__examples__ = ""
Added: trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
2004-03-05 18:06:40 UTC (rev 5231)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
2004-03-05 19:58:55 UTC (rev 5232)
@@ -0,0 +1,74 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or(at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2000-2004 Free Software Foundation
+#
+# FILE:
+# postgresql/Connection.py
+#
+# DESCRIPTION:
+# Postgresql implementation of dbdriver using Python DB-SIG v2
+# specification.
+#
+# NOTES:
+#
+
+__all__ = ('Connection')
+
+from gnue.common.datasources import GDataObjects, GConditions, GConnections
+from gnue.common.apps import GDebug
+
+try:
+ import pgdb
+ from _pg import error as PGError # This is so we can catch login errors
+except ImportError, message:
+ tmsg = _("Driver not installed: pygresql for PostgreSQL [%s]") % message
+ raise GConnections.AdapterNotInstalled, tmsg
+
+from gnue.common.datasources.drivers.postgresql import Base
+
+class Connection(Base.Connection):
+ _pg_driver = pgdb
+ _DatabaseError = pgdb.Error
+
+ def connect(self, connectData={}):
+ GDebug.printMesg(1,"Postgresql database driver initializing")
+ try:
+ self.native = pgdb.connect(user=connectData['_username'],
+ password=connectData['_password'],
+ host=connectData['host'],
+ database=connectData['dbname'])
+ except PGError, value:
+ raise GDataObjects.LoginError, value
+ except self._DatabaseError, value:
+ raise GDataObjects.LoginError, value
+
+ try:
+ encoding = connectData['encoding']
+ GDebug.printMesg(1,'Setting postgresql client_encoding to %s' % encoding)
+ cursor = self.native.cursor()
+ cursor.execute("SET CLIENT_ENCODING TO '%s'" % encoding)
+ cursor.close()
+ except KeyError:
+ pass
+ except self._DatabaseError:
+ try:
+ cursor.close()
+ except:
+ pass
+
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
2004-03-05 18:06:40 UTC (rev 5231)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
2004-03-05 19:58:55 UTC (rev 5232)
@@ -28,53 +28,6 @@
# NOTES:
#
-__all__ = ('Connection')
-
-from gnue.common.datasources import GDataObjects, GConditions, GConnections
-from gnue.common.apps import GDebug
-
-try:
- import pgdb
- from _pg import error as PGError # This is so we can catch login errors
-except ImportError, message:
- tmsg = _("Driver not installed: pygresql for PostgreSQL [%s]") % message
- raise GConnections.AdapterNotInstalled, tmsg
-
-from gnue.common.datasources.drivers.postgresql import Base
-
-
-class Connection(Base.Connection):
- _pg_driver = pgdb
- _DatabaseError = pgdb.Error
-
- def connect(self, connectData={}):
- GDebug.printMesg(1,"Postgresql database driver initializing")
- try:
- self.native = pgdb.connect(user=connectData['_username'],
- password=connectData['_password'],
- host=connectData['host'],
- database=connectData['dbname'])
- except PGError, value:
- raise GDataObjects.LoginError, value
- except self._DatabaseError, value:
- raise GDataObjects.LoginError, value
-
- try:
- encoding = connectData['encoding']
- GDebug.printMesg(1,'Setting postgresql client_encoding to %s' % encoding)
- cursor = self.native.cursor()
- cursor.execute("SET CLIENT_ENCODING TO '%s'" % encoding)
- cursor.close()
- except KeyError:
- pass
- except self._DatabaseError:
- try:
- cursor.close()
- except:
- pass
-
-
-
__description__ = _("PyGreSQL Data Driver for PostgreSQL")
__driverurl__ = "http://????"
__examples__ = ""
@@ -84,7 +37,7 @@
# Stub code to not initialize the Connection until needed.
# This greatly helps with error messages.
#
-#def Connection(*args, **parms):
-# from Driver import Connection as C
-# return C(*args, **parms)
+def Connection(*args, **parms):
+ from Driver import Connection as C
+ return C(*args, **parms)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5232 - in trunk/gnue-common/src/datasources: . drivers/postgresql/psycopg drivers/postgresql/pygresql,
jan <=