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 |
|
# _dbsig/DBdriver.py |
23 |
|
# |
24 |
|
# DESCRIPTION: |
25 |
|
# Generic implementation of dbdriver using Python DB-SIG v2 |
26 |
|
# specification. |
27 |
|
# |
28 |
|
# NOTES: |
29 |
|
# The classes below are meant to be extended |
30 |
|
# |
31 |
|
# HISTORY: |
32 |
|
# |
33 |
|
|
34 |
|
__all__ = ['Connection'] |
35 |
|
|
36 |
|
from gnue.common.datasources import Exceptions |
37 |
|
from gnue.common.datasources.drivers.Base.Connection import Connection as BaseConnection |
38 |
|
from gnue.common.apps import GDebug |
39 |
|
import string |
40 |
|
import types |
41 |
|
|
42 |
|
class Connection(BaseConnection): |
43 |
|
|
44 |
|
# This should be over-ridden only if driver needs more than user/pass |
45 |
|
def getLoginFields(self): |
46 |
|
return [['_username', _('User Name'),0],['_password', _('Password'),1]] |
47 |
|
|
48 |
|
def commit(self): |
49 |
|
GDebug.printMesg (5,"DB-SIG database driver: commit()") |
50 |
|
|
51 |
|
try: |
52 |
|
self.native.commit() |
53 |
|
except self._DatabaseError, value: |
54 |
|
raise Exceptions.ConnectionError, value |
55 |
|
|
56 |
|
self._beginTransaction() |
57 |
|
|
58 |
|
def rollback(self): |
59 |
|
GDebug.printMesg (5,"DB-SIG database driver: rollback()") |
60 |
|
|
61 |
|
try: |
62 |
|
self.native.rollback() |
63 |
|
except: |
64 |
|
pass # I'm SURE this isn't right (jcater) |
65 |
|
# But not all db's support transactions |
66 |
|
|
67 |
|
self._beginTransaction() |
68 |
|
|
69 |
|
|
70 |
|
# Code necessary to force the connection into transaction mode... |
71 |
|
# this is usually not necessary (MySQL is one of few DBs that must force) |
72 |
|
def _beginTransaction(self): |
73 |
|
pass |