/[gnue]/gnue-common/src/datasources/drivers/ingres/ingres/ResultSet.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/ingres/ingres/ResultSet.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jcater, Fri Oct 10 01:21:18 2003 UTC revision 1.2 by jcater, Tue Nov 25 17:01:35 2003 UTC
# Line 0  Line 1 
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-2003 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.DBSIG2.Driver \
45       import DBSIG2.RecordSet, DBSIG2.ResultSet, DBSIG2.DataObject, \
46              DBSIG2.DataObject_SQL, DBSIG2.DataObject_Object
47    
48    try:
49      import ingmod as SIG2api
50    except ImportError, message:
51      tmsg = _("Driver not installed: ingmod for Ingres/Ingres II/OpenIngres [%s]") % message
52      raise GConnections.AdapterNotInstalled, tmsg
53    
54    
55    class Ingres_RecordSet(DBSIG2.RecordSet):
56      pass
57    
58    
59    class Ingres_ResultSet(DBSIG2.ResultSet):
60      def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):
61        DBSIG2.ResultSet.__init__(self, dataObject, \
62                cursor, defaultValues, masterRecordSet)
63        self._recordSetClass = Ingres_RecordSet
64    
65    
66    class Ingres_DataObject(DBSIG2.DataObject):
67      def __init__(self):
68        DBSIG2.DataObject.__init__(self)
69        self._DatabaseError = SIG2api.DatabaseError
70        self._resultSetClass = Ingres_ResultSet
71    
72    
73      def connect(self, connectData={}):
74        GDebug.printMesg(1,"Ingres database driver initializing")
75        try:
76          # TODO: I have no clue how to pass a Password!!!!!
77          self._dataConnection = SIG2api.connect(connectData['dbname'], \
78                    user=connectData['_username'])
79        except self._DatabaseError, value:
80          raise GDataObjects.LoginError, value
81    
82        self._postConnect()
83    
84    
85    
86      #
87      # Schema (metadata) functions
88      #
89    
90      # TODO: See postgresql for an example of what these functions do.
91    
92      # Return a list of the types of Schema objects this driver provides
93      def getSchemaTypes(self):
94        return [('view',_('Views'),1),
95                ('table',_('Tables'),1)]
96    
97      # Return a list of Schema objects
98      def getSchemaList(self, type=None):
99        return []
100    
101      # Find a schema object with specified name
102      def getSchemaByName(self, name, type=None):
103        return None
104    
105      def _postConnect(self):
106        self.triggerExtensions = TriggerExtensions(self._dataConnection)
107    
108    
109    class Ingres_DataObject_Object(Ingres_DataObject, \
110          DBSIG2.DataObject_Object):
111    
112      def __init__(self):
113        Ingres_DataObject.__init__(self)
114    
115      def _buildQuery(self, conditions={},forDetail=None,additionalSQL=""):
116        return DBSIG2.DataObject_Object._buildQuery(self, conditions,forDetail, additionalSQL)
117    
118    
119    class Ingres_DataObject_SQL(Ingres_DataObject, \
120          DBSIG2.DataObject_SQL):
121      def __init__(self):
122        # Call DBSIG init first because Ingres_DataObject needs to overwrite
123        # some of its values
124        DBSIG2.DataObject_SQL.__init__(self)
125        Ingres_DataObject.__init__(self)
126    
127      def _buildQuery(self, conditions={}):
128        return DBSIG2.DataObject_SQL._buildQuery(self, conditions)
129    
130    
131    #
132    #  Extensions to Trigger Namespaces
133    #
134    class TriggerExtensions:
135    
136      def __init__(self, connection):
137        self.__connection = connection
138    
139    
140    
141    ######################################
142    #
143    #  The following hashes describe
144    #  this driver's characteristings.
145    #
146    ######################################
147    
148    #
149    #  All datasouce "types" and corresponding DataObject class
150    #
151    supportedDataObjects = {
152      'object': Ingres_DataObject_Object,
153      'sql':    Ingres_DataObject_SQL
154    }
155    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26