/[gnue]/gnue-common/src/datasources/drivers/gadfly/gadfly/Connection.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/gadfly/gadfly/Connection.py

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

revision 1.1 by jcater, Fri Oct 10 01:21:15 2003 UTC revision 1.2 by jcater, Tue Nov 25 17:01:33 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    # gadfly/DBdriver.py
23    #
24    # DESCRIPTION:
25    # Driver to provide access to data via Gadfly
26    #
27    # NOTES:
28    # The Gadfly notes state that it is not safe to use in a multi-user environment
29    # where there may be concurrent read/writes. Use at own risk :)
30    
31    __all__ = ['Connection']
32    
33    import string
34    import sys
35    from gnue.common.apps import GDebug
36    from gnue.common.datasources import GDataObjects
37    from gnue.common.datasources.drivers import DBSIG2
38    
39    try:
40      import gadfly
41    except ImportError, message:
42      tmsg = _("Driver not installed: gadfly driver\n\n[%s") % message
43      raise GConnections.AdapterNotInstalled, tmsg
44    
45    
46    
47    ##### EVIL HACK
48    class Error(StandardError):
49      """Generic Error"""
50    
51    class InterfaceError(Error):
52      """Interface Error"""
53    
54    class DatabaseError(InterfaceError):
55      """DB Error"""
56    
57    class DataError(DatabaseError):
58      """Data Error"""
59    
60    class OperationalError(DatabaseError):
61      """Operational Error"""
62    
63    class IntegrityError(DatabaseError):
64      """Integrity Error"""
65    
66    ##### END EVIL HACK
67    
68    class Connection(DBSIG2.Connection):
69    
70      _DatabaseError = Error
71      supportedDataObjects = {
72       'object': DataObject_Object,
73       'sql':    DataObject_SQL
74      }
75    
76      def connect(self, connectData={}):
77        GDebug.printMesg(1,"Gadfly database driver initializing")
78        #GDebug.printMesg(1,"Connecting with %s, %s" %( connectData['_dbname'], connectData['directory']))
79        try:
80          self.native = gadfly.gadfly(connectData['dbname'],
81                                               connectData['directory'])
82        except self._DatabaseError, value:
83          #GDebug.printMesg(1,"Boom")
84          raise GDataObjects.LoginError, value
85    
86        self._beginTransaction()
87    
88    
89      def _beginTransaction(self):
90        try:
91          self.native.begin()
92        except:
93          pass
94    
95      # This should be over-ridden only if driver needs more than user/pass
96      def getLoginFields(self):
97        return []
98    
99    
100      #
101      # Extensions
102      #
103    
104      # Return the current date, according to database
105    #  def getDate(self):
106    #    pass
107    
108      # Return a sequence number from sequence 'name'
109    #  def getSequence(self, name):
110    #    pass
111    
112      # Run the SQL statement 'statement'
113    #  def sql(self, statement):
114    #    pass
115    

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