2
# This file is part of GNU Enterprise.
4
# GNU Enterprise is free software; you can redistribute it
5
# and/or modify it under the terms of the GNU General Public
6
# License as published by the Free Software Foundation; either
7
# version 2, or (at your option) any later version.
9
# GNU Enterprise is distributed in the hope that it will be
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public
15
# License along with program; see the file COPYING. If not,
16
# write to the Free Software Foundation, Inc., 59 Temple Place
17
# - Suite 330, Boston, MA 02111-1307, USA.
19
# Copyright 2000-2005 Free Software Foundation
25
# Driver to provide access to data via Holger Meyer's Ingres/Python Driver
26
# (including OpenIngres 1.2, CA Ingres 6.4, CA Ingres II)
27
# Requires ingmod (http://www.informatik.uni-rostock.de/~hme/software/)
31
# Supported attributes (via connections.conf or <database> tag)
33
# dbame= This is the Ingres database to use (required)
36
#### THIS IS AN UNTESTED DRIVER ####
37
#### Any volunteers? ####
40
from string import lower
42
from gnue.common.datasources import GDataObjects, GConditions
43
from gnue.common.apps import GDebug
44
from gnue.common.datasources.drivers import DBSIG2
46
raise "This data driver has not been upgraded to the new format."
49
import ingmod as SIG2api
52
class Ingres_RecordSet(DBSIG2.RecordSet):
56
class Ingres_ResultSet(DBSIG2.ResultSet):
57
def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):
58
DBSIG2.ResultSet.__init__(self, dataObject, \
59
cursor, defaultValues, masterRecordSet)
60
self._recordSetClass = Ingres_RecordSet
63
class Ingres_DataObject(DBSIG2.DataObject):
65
DBSIG2.DataObject.__init__(self)
66
self._DatabaseError = SIG2api.DatabaseError
67
self._resultSetClass = Ingres_ResultSet
70
def connect(self, connectData={}):
71
GDebug.printMesg(9,"Ingres database driver initializing")
73
# TODO: I have no clue how to pass a Password!!!!!
74
self._dataConnection = SIG2api.connect(connectData['dbname'], \
75
user=connectData['_username'])
76
except self._DatabaseError, value:
77
raise GDataObjects.LoginError, value
84
# Schema (metadata) functions
87
# TODO: See postgresql for an example of what these functions do.
89
# Return a list of the types of Schema objects this driver provides
90
def getSchemaTypes(self):
91
return [('view',_('Views'),1),
92
('table',_('Tables'),1)]
94
# Return a list of Schema objects
95
def getSchemaList(self, type=None):
98
# Find a schema object with specified name
99
def getSchemaByName(self, name, type=None):
102
def _postConnect(self):
103
self.triggerExtensions = TriggerExtensions(self._dataConnection)
106
class Ingres_DataObject_Object(Ingres_DataObject, \
107
DBSIG2.DataObject_Object):
110
Ingres_DataObject.__init__(self)
112
def _buildQuery(self, conditions={},forDetail=None,additionalSQL=""):
113
return DBSIG2.DataObject_Object._buildQuery(self, conditions,forDetail, additionalSQL)
116
class Ingres_DataObject_SQL(Ingres_DataObject, \
117
DBSIG2.DataObject_SQL):
119
# Call DBSIG init first because Ingres_DataObject needs to overwrite
121
DBSIG2.DataObject_SQL.__init__(self)
122
Ingres_DataObject.__init__(self)
124
def _buildQuery(self, conditions={}):
125
return DBSIG2.DataObject_SQL._buildQuery(self, conditions)
129
# Extensions to Trigger Namespaces
131
class TriggerExtensions:
133
def __init__(self, connection):
134
self.__connection = connection
138
######################################
140
# The following hashes describe
141
# this driver's characteristings.
143
######################################
146
# All datasouce "types" and corresponding DataObject class
148
supportedDataObjects = {
149
'object': Ingres_DataObject_Object,
150
'sql': Ingres_DataObject_SQL