~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/datasources/drivers/ingres/ingres/ResultSet.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of GNU Enterprise.
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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.
 
18
#
 
19
# Copyright 2000-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# ingres/DBdriver.py
 
23
#
 
24
# DESCRIPTION:
 
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/)
 
28
#
 
29
# NOTES:
 
30
#
 
31
#   Supported attributes (via connections.conf or <database> tag)
 
32
#
 
33
#     dbame=      This is the Ingres database to use (required)
 
34
#
 
35
 
 
36
#### THIS IS AN UNTESTED DRIVER ####
 
37
####      Any volunteers?       ####
 
38
 
 
39
 
 
40
from string import lower
 
41
import sys
 
42
from gnue.common.datasources import GDataObjects, GConditions
 
43
from gnue.common.apps import GDebug
 
44
from gnue.common.datasources.drivers import DBSIG2
 
45
 
 
46
raise "This data driver has not been upgraded to the new format."
 
47
 
 
48
 
 
49
import ingmod as SIG2api
 
50
 
 
51
 
 
52
class Ingres_RecordSet(DBSIG2.RecordSet):
 
53
  pass
 
54
 
 
55
 
 
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
 
61
 
 
62
 
 
63
class Ingres_DataObject(DBSIG2.DataObject):
 
64
  def __init__(self):
 
65
    DBSIG2.DataObject.__init__(self)
 
66
    self._DatabaseError = SIG2api.DatabaseError
 
67
    self._resultSetClass = Ingres_ResultSet
 
68
 
 
69
 
 
70
  def connect(self, connectData={}):
 
71
    GDebug.printMesg(9,"Ingres database driver initializing")
 
72
    try:
 
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
 
78
 
 
79
    self._postConnect()
 
80
 
 
81
 
 
82
 
 
83
  #
 
84
  # Schema (metadata) functions
 
85
  #
 
86
 
 
87
  # TODO: See postgresql for an example of what these functions do.
 
88
 
 
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)]
 
93
 
 
94
  # Return a list of Schema objects
 
95
  def getSchemaList(self, type=None):
 
96
    return []
 
97
 
 
98
  # Find a schema object with specified name
 
99
  def getSchemaByName(self, name, type=None):
 
100
    return None
 
101
 
 
102
  def _postConnect(self):
 
103
    self.triggerExtensions = TriggerExtensions(self._dataConnection)
 
104
 
 
105
 
 
106
class Ingres_DataObject_Object(Ingres_DataObject, \
 
107
      DBSIG2.DataObject_Object):
 
108
 
 
109
  def __init__(self):
 
110
    Ingres_DataObject.__init__(self)
 
111
 
 
112
  def _buildQuery(self, conditions={},forDetail=None,additionalSQL=""):
 
113
    return DBSIG2.DataObject_Object._buildQuery(self, conditions,forDetail, additionalSQL)
 
114
 
 
115
 
 
116
class Ingres_DataObject_SQL(Ingres_DataObject, \
 
117
      DBSIG2.DataObject_SQL):
 
118
  def __init__(self):
 
119
    # Call DBSIG init first because Ingres_DataObject needs to overwrite
 
120
    # some of its values
 
121
    DBSIG2.DataObject_SQL.__init__(self)
 
122
    Ingres_DataObject.__init__(self)
 
123
 
 
124
  def _buildQuery(self, conditions={}):
 
125
    return DBSIG2.DataObject_SQL._buildQuery(self, conditions)
 
126
 
 
127
 
 
128
#
 
129
#  Extensions to Trigger Namespaces
 
130
#
 
131
class TriggerExtensions:
 
132
 
 
133
  def __init__(self, connection):
 
134
    self.__connection = connection
 
135
 
 
136
 
 
137
 
 
138
######################################
 
139
#
 
140
#  The following hashes describe
 
141
#  this driver's characteristings.
 
142
#
 
143
######################################
 
144
 
 
145
#
 
146
#  All datasouce "types" and corresponding DataObject class
 
147
#
 
148
supportedDataObjects = {
 
149
  'object': Ingres_DataObject_Object,
 
150
  'sql':    Ingres_DataObject_SQL
 
151
}
 
152