[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5004 - in trunk/gnue-common/src/datasources/drivers: oracle/Base oracle
From: |
jcater |
Subject: |
r5004 - in trunk/gnue-common/src/datasources/drivers: oracle/Base oracle/cxoracle oracle/dcoracle postgresql/Base |
Date: |
Fri, 19 Dec 2003 12:59:07 -0600 (CST) |
Author: jcater
Date: 2003-12-19 12:59:04 -0600 (Fri, 19 Dec 2003)
New Revision: 5004
Removed:
trunk/gnue-common/src/datasources/drivers/oracle/Base/RecordSet.py
Modified:
trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py
trunk/gnue-common/src/datasources/drivers/oracle/Base/DataObject.py
trunk/gnue-common/src/datasources/drivers/oracle/Base/ResultSet.py
trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py
trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/__init__.py
trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py
trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/__init__.py
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
Log:
more work on Oracle conversion to new DataObject style
Modified: trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -19,7 +19,7 @@
# Copyright 2000-2003 Free Software Foundation
#
# FILE:
-# cxoracle/DBdriver.py
+# Oracle/Base/Connection.py
#
# DESCRIPTION:
# Driver to provide access to data via Computronix's Oracle/Python Driver
@@ -38,8 +38,8 @@
from gnue.common.datasources import GDataObjects, GConditions
from gnue.common.apps import GDebug
from gnue.common.datasources.drivers import DBSIG2
-
from gnue.common.datasources.drivers.oracle.Schema.Discovery.Introspection
import Introspection
+from DataObject import *
#
@@ -48,9 +48,35 @@
class Connection(DBSIG2.Connection):
defaultBehavior = Introspection
+ supportedDataObjects = {
+ 'object': DataObject_Object,
+ 'sql': DataObject_SQL
+ }
-
+ _sig_driver = None
+ _dateTimeFormat = "'%Y-%m-%d %H:%M:%S'"
+
#
+ # Connect to database
+ def connect(self, connectData={}):
+ GDebug.printMesg(1,"Oracle database driver initializing")
+
+ if not hasattr(self,'_DatabaseError'):
+ self._DatabaseError = self._sig_driver.DatabaseError
+
+ try:
+ self._dataConnection = SIG2api.connect("%s/address@hidden" \
+ % (connectData['_username'], \
+ connectData['_password'], \
+ connectData['service']))
+ except self._DatabaseError, value:
+ raise GDataObjects.LoginError, value
+
+ if connectData.has_key('datetimeformat'):
+ self._dateTimeFormat = "'%s'" % connectData['datetimeformat']
+
+
+ #
# Extensions
#
@@ -73,7 +99,7 @@
raise
try:
return cursor.fetchall()
- except:
+ except:
return None
# Used internally
Modified: trunk/gnue-common/src/datasources/drivers/oracle/Base/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/Base/DataObject.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/Base/DataObject.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -19,11 +19,9 @@
# Copyright 2000-2003 Free Software Foundation
#
# FILE:
-# cxoracle/DBdriver.py
+# Oracle/Base/DataObject.py
#
# DESCRIPTION:
-# Driver to provide access to data via Computronix's Oracle/Python Driver
-# Requires cx_Oracle 2.2+ (http://www.computronix.com/utilities/)
#
# NOTES:
#
@@ -40,7 +38,26 @@
class _Base:
_escapeSingleQuote = '\'\''
_dateTimeFormat = "'%Y-%m-%d %H:%M:%S'"
+ _primaryIdChecked = 0
+ def _checkForPrimaryId(self):
+
+ self._primaryIdChecked = 1
+
+ try:
+ statement = "select rowidtochar(rowid) from %s where 1=2" % self.table
+ cursor = self._connection.cursor()
+ cursor.execute(statement)
+ cursor.close()
+
+ self._primaryIdSelect = "ROWIDTOCHAR(ROWID) as GNUE__ROWID__"
+ self._primaryIdField = "gnue__rowid__" # Keep this lowercase!!!
+ self._primaryIdFormat = "ROWID = CHARTOROWID('%s')"
+ GDebug.printMesg(5,'View %s is using ROWID identifier' % self.table)
+
+ except self._DatabaseError:
+ GDebug.printMesg (5, 'View %s has no internal ROWID' % self.table)
+
class DataObject_SQL(_Base, DBSIG2.DataObject_SQL):
pass
Deleted: trunk/gnue-common/src/datasources/drivers/oracle/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/Base/RecordSet.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/Base/RecordSet.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -1,38 +0,0 @@
-#
-# 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-2003 Free Software Foundation
-#
-# FILE:
-# cxoracle/DBdriver.py
-#
-# DESCRIPTION:
-# Driver to provide access to data via Computronix's Oracle/Python Driver
-# Requires cx_Oracle 2.2+ (http://www.computronix.com/utilities/)
-#
-# NOTES:
-#
-# Supported attributes (via connections.conf or <database> tag)
-#
-# service= This is the Oracle TNS name for your connection (required)
-#
-
-import sys, string
-from gnue.common.datasources import GDataObjects, GConditions
-from gnue.common.apps import GDebug
-
Modified: trunk/gnue-common/src/datasources/drivers/oracle/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/Base/ResultSet.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/Base/ResultSet.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -27,10 +27,8 @@
__all__ = ['ResultSet']
from gnue.common.datasources.drivers import DBSIG2
-from RecordSet import RecordSet
class ResultSet(DBSIG2.ResultSet):
_uniqueIdField = "__GNUeF__uniqueKey_%s" % (self._dataObject.table)
_uniqueIdFormat = "ROWID='%s'"
- _recordSetClass = RecordSet
Modified: trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -22,125 +22,21 @@
# cxoracle/DBdriver.py
#
# DESCRIPTION:
-# Driver to provide access to data via Computronix's Oracle/Python Driver
-# Requires cx_Oracle 2.2+ (http://www.computronix.com/utilities/)
#
# NOTES:
#
-# Supported attributes (via connections.conf or <database> tag)
-#
-# service= This is the Oracle TNS name for your connection (required)
-#
-import sys, string
-from gnue.common.apps import GDebug
-from gnue.common.datasources import GDataObjects, GConnections
-from gnue.common.datasources.drivers import DBSIG2
-raise "This data driver has not been upgraded to the new format."
+from gnue.common.datasources import Exceptions
+from gnue.common.datasources.drivers.oracle import Base
-
-from gnue.common.datasources.drivers.oracle.Base.Driver import Oracle_Schema
-
try:
import cx_Oracle as SIG2api
except ImportError, message:
tmsg = _("Driver not installed: cx_Oracle for Oracle 8.x [%s]") % message
- raise GConnections.AdapterNotInstalled, tmsg
+ raise Exceptions.AdapterNotInstalled, tmsg
+class Connection(Base.Connection):
+ _sig_driver = SIG2api
+ _DatabaseError = SIG2api.DatabaseError
-class Oracle_RecordSet(DBSIG2.RecordSet):
- pass
-
-
-class Oracle_ResultSet(DBSIG2.ResultSet):
- def __init__(self, dataObject, cursor=None, defaultValues={},
masterRecordSet=None):
- DBSIG2.ResultSet.__init__(self, dataObject, \
- cursor, defaultValues, masterRecordSet)
- self._recordSetClass = Oracle_RecordSet
-
-
-class Oracle_DataObject(Oracle_Schema, DBSIG2.DataObject):
- def __init__(self):
- Oracle_Schema.__init__(self)
- DBSIG2.DataObject.__init__(self)
- self._DatabaseError = SIG2api.DatabaseError
- self._resultSetClass = Oracle_ResultSet
-
- # The date/time format used in insert/select statements
- # (based on format used for time.strftime())
- self._dateTimeFormat = "to_date('%Y-%m-%d %H:%M:%S','yyyy-mm-dd hh:mi:ss')"
-
-
- def connect(self, connectData={}):
- GDebug.printMesg(1,"Oracle database driver initializing")
- try:
- self._dataConnection = SIG2api.connect("%s/address@hidden" \
- % (connectData['_username'], \
- connectData['_password'], \
- connectData['service']))
- except self._DatabaseError, value:
- raise GDataObjects.LoginError, value
-
- self._postConnect()
-
-
-class Oracle_DataObject_Object(Oracle_DataObject, \
- DBSIG2.DataObject_Object):
-
- def __init__(self):
- Oracle_DataObject.__init__(self)
- self._primaryIdChecked = 0
-
-
- def _buildQuery(self, conditions={},forDetail=None,additionalSQL=""):
- return DBSIG2.DataObject_Object._buildQuery(self,
conditions,forDetail,additionalSQL)
-
- def _checkForPrimaryId(self):
-
- self._primaryIdChecked = 1
-
- try:
- statement = "select rowidtochar(rowid) from %s where 1=2" % self.table
- cursor = self._dataConnection.cursor()
- cursor.execute(statement)
- cursor.close()
-
- self._primaryIdSelect = "ROWIDTOCHAR(ROWID) as GNUE__ROWID__"
- self._primaryIdField = "gnue__rowid__" # Keep this lowercase!!!
- self._primaryIdFormat = "ROWID = CHARTOROWID('%s')"
- GDebug.printMesg(5,'View %s is using ROWID identifier' % self.table)
-
- except self._DatabaseError:
- GDebug.printMesg (5, 'View %s has no internal ROWID' % self.table)
-
-
-class Oracle_DataObject_SQL(Oracle_DataObject, \
- DBSIG2.DataObject_SQL):
- def __init__(self):
- # Call DBSIG init first because Oracle_DataObject needs to overwrite
- # some of its values
- DBSIG2.DataObject_SQL.__init__(self)
- Oracle_DataObject.__init__(self)
-
- def _buildQuery(self, conditions={}):
- return DBSIG2.DataObject_SQL._buildQuery(self, conditions)
-
-
-
-
-######################################
-#
-# The following hashes describe
-# this driver's characteristings.
-#
-######################################
-
-#
-# All datasouce "types" and corresponding DataObject class
-#
-supportedDataObjects = {
- 'object': Oracle_DataObject_Object,
- 'sql': Oracle_DataObject_SQL
-}
-
Modified: trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/__init__.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/__init__.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -29,8 +29,13 @@
#
__description__ = _("CX_Oracle Data Driver for Oracle 7.3/8i/9i+ (OCI8)")
-__driverurl__ = "http://????"
-__examples__ = ""
+__driverurl__ = "http://www.computronix.com/utilities/"
+__examples__ = """
+ Supported attributes (via connections.conf or <connection> tag)
+
+ service= This is the Oracle TNS name for your connection (required)
+"""
+
__doc__ = ""
#
Modified: trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -12,8 +12,8 @@
# 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
+# 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-2003 Free Software Foundation
@@ -22,122 +22,21 @@
# oracle/DBdriver.py
#
# DESCRIPTION:
-# Driver to provide access to data via Digital Creations Oracle/Python Driver
-# Requires DCOracle2 2.x (http://www.zope.org/Products/DCOracle2/)
#
# NOTES:
#
-# Supported attributes (via connections.conf or <database> tag)
-#
-# service= This is the Oracle TNS name for your connection (required)
-#
-import string
-import sys
-from gnue.common.datasources import GDataObjects, GConditions, GConnections
-from gnue.common.apps import GDebug
-from gnue.common.datasources.drivers import DBSIG2
-raise "This data driver has not been upgraded to the new format."
+from gnue.common.datasources import Exceptions
+from gnue.common.datasources.drivers.oracle import Base
-
-from gnue.common.datasources.drivers.oracle.Base.Driver import Oracle_Schema
-
try:
import DCOracle2 as SIG2api
except ImportError, message:
tmsg = _("Driver not installed: DCOracle2 [%s]") % message
raise GConnections.AdapterNotInstalled, tmsg
+class Connection(Base.Connection):
+ _sig_driver = SIG2api
+ _DatabaseError = SIG2api.DatabaseError
-
-class Oracle_ResultSet(DBSIG2.ResultSet):
- _uniqueIdField = "__GNUeF__uniqueKey_%s" % (self._dataObject.table)
- _uniqueIdFormat = "ROWID='%s'"
-
-
-
-class Oracle_DataObject(DBSIG2.DataObject):
- def __init__(self):
- Oracle_Schema.__init__(self)
- DBSIG2.DataObject.__init__(self)
- self._DatabaseError = SIG2api.DatabaseError
- self._resultSetClass = Oracle_ResultSet
-
-
- def connect(self, connectData={}):
- GDebug.printMesg(1,"Oracle database driver initializing")
- try:
- self._dataConnection = SIG2api.connect("%s/address@hidden" \
- % (connectData['_username'], \
- connectData['_password'], \
- connectData['service']))
- except self._DatabaseError, value:
- raise GDataObjects.LoginError, value
-
- if connectData.has_key('datetimeformat'):
- self._dateTimeFormat = "'%s'" % connectData['datetimeformat']
-
-
-
-
-class Oracle_DataObject_Object(Oracle_DataObject, \
- DBSIG2.DataObject_Object):
-
- def __init__(self):
- Oracle_DataObject.__init__(self)
- self._primaryIdChecked = 0
-
-
- def _buildQuery(self, conditions={},forDetail=None,additionalSQL=""):
- return DBSIG2.DataObject_Object._buildQuery(self, conditions, forDetail,
additionalSQL)
-
- def _checkForPrimaryId(self):
-
- self._primaryIdChecked = 1
-
- try:
- statement = "select rowidtochar(rowid) from %s where 1=2" % self.table
- cursor = self._dataConnection.cursor()
- cursor.execute(statement)
- cursor.close()
-
- self._primaryIdSelect = "ROWIDTOCHAR(ROWID) as GNUE__ROWID__"
- self._primaryIdField = "gnue__rowid__" # Keep this lowercase!!!
- self._primaryIdFormat = "ROWID = CHARTOROWID('%s')"
- GDebug.printMesg(5,'View %s is using ROWID identifier' % self.table)
-
- except self._DatabaseError:
- GDebug.printMesg (5, 'View %s has no internal ROWID' % self.table)
-
-
-class Oracle_DataObject_SQL(Oracle_DataObject, \
- DBSIG2.DataObject_SQL):
- def __init__(self):
- # Call DBSIG init first because Oracle_DataObject needs to overwrite
- # some of its values
- DBSIG2.DataObject_SQL.__init__(self)
- Oracle_DataObject.__init__(self)
-
- def _buildQuery(self, conditions={}):
- return DBSIG2.DataObject_SQL._buildQuery(self, conditions)
-
-
-
-######################################
-#
-# The following hashes describe
-# this driver's characteristings.
-#
-######################################
-
-#
-# All datasouce "types" and corresponding DataObject class
-#
-supportedDataObjects = {
- 'object': Oracle_DataObject_Object,
- 'sql': Oracle_DataObject_SQL
-}
-
-
-
Modified: trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/__init__.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/__init__.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -29,8 +29,12 @@
#
__description__ = _("DCOracle2 Data Driver for Oracle 7.3/8i/9i+ (OCI8)")
-__driverurl__ = "http://????"
-__examples__ = ""
+__driverurl__ = "http://www.zope.org/Products/DCOracle2/"
+__examples__ = """
+ Supported attributes (via connections.conf or <connection> tag)
+
+ service= This is the Oracle TNS name for your connection (required)
+"""
__doc__ = ""
#
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2003-12-19 16:54:16 UTC (rev 5003)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2003-12-19 18:59:04 UTC (rev 5004)
@@ -58,8 +58,6 @@
def connect(self, connectData):
- print "Postgresql database driver initializing"
-
if not hasattr(self,'_DatabaseError'):
self._DatabaseError = self._pg_driver.DatabaseError
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5004 - in trunk/gnue-common/src/datasources/drivers: oracle/Base oracle/cxoracle oracle/dcoracle postgresql/Base,
jcater <=