[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-common/src GDataObjects.py dbdrivers/...
From: |
James Thompson |
Subject: |
gnue/gnue-common/src GDataObjects.py dbdrivers/... |
Date: |
Tue, 18 Sep 2001 17:58:25 -0400 |
CVSROOT: /cvs
Module name: gnue
Changes by: James Thompson <address@hidden> 01/09/18 17:58:25
Modified files:
gnue-common/src: GDataObjects.py
gnue-common/src/dbdrivers/_dbsig: DBdriver.py
gnue-common/src/dbdrivers/db2: DBdriver.py
Added files:
gnue-common/src/dbdrivers/pypgsql: DBdriver.py __init__.py
Log message:
Added pypgsql driver (supports win32)
Misc changes to _dbsig driver to work with diff implementations of the
DBSIG API
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GDataObjects.py.diff?cvsroot=OldCVS&tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py.diff?cvsroot=OldCVS&tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/dbdrivers/db2/DBdriver.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/dbdrivers/pypgsql/DBdriver.py?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/dbdrivers/pypgsql/__init__.py?cvsroot=OldCVS&rev=1.1
Patches:
Index: gnue/gnue-common/src/GDataObjects.py
diff -u gnue/gnue-common/src/GDataObjects.py:1.22
gnue/gnue-common/src/GDataObjects.py:1.23
--- gnue/gnue-common/src/GDataObjects.py:1.22 Tue Sep 18 14:18:46 2001
+++ gnue/gnue-common/src/GDataObjects.py Tue Sep 18 17:58:25 2001
@@ -287,11 +287,10 @@
# returns # of records the
def getRecordCount(self):
- return self._recordCount
+ return self._recordCount > 0 and self._recordCount or self.getCacheCount()
# Get a specific record (0=based)
def getRecord(self, record):
- print "GDataObjects.py record %s, cached %s " % (record,
len(self._cachedRecords))
while (record + 1 > len(self._cachedRecords)) and self._loadNextRecord():
pass
@@ -526,7 +525,6 @@
else:
fn = string.lower(field)
self._fields[fn] = "%s" % value
- print "I set %s to %s with a modtrack of %s" %(fn,value,trackMod)
if trackMod == 1:
self._emptyFlag = 0
if self._parent.isFieldBound(field):
Index: gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py
diff -u gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py:1.18
gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py:1.19
--- gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py:1.18 Tue Sep 18
14:18:46 2001
+++ gnue/gnue-common/src/dbdrivers/_dbsig/DBdriver.py Tue Sep 18 17:58:25 2001
@@ -138,8 +138,9 @@
self,dataObject,cursor,defaultValues,masterRecordSet)
self._recordSetClass = DBSIG_RecordSet
self._fieldNames = None
- self._recordCount = cursor.rowcount
+ self._recordCount = cursor.rowcount > 0 and cursor.rowcount or 0
+
# If a DB driver supports a unique identifier for rows,
# list it here. _primaryIdField is the field name (lower case)
# that would appear in the recordset (note that this can be
@@ -170,24 +171,24 @@
def _loadNextRecord(self):
if self._cursor:
+ rs = None
try:
rs = self._cursor.fetchone()
except self._dataObject._DatabaseError, err:
- raise GDataObjects.ConnectionError, err
+ pass
+# TODO: It seems that popy does what the other drivers don't
+# TODO: and raises this error ALOT need to find out why
+# raise GDataObjects.ConnectionError, err
- GDebug.printMesg(5, rs)
- if not self._fieldNames:
- self._fieldNames = []
- for t in (self._cursor.description):
- self._fieldNames.append (string.lower(t[0]))
if rs:
+ if not self._fieldNames:
+ self._fieldNames = []
+ for t in (self._cursor.description):
+ self._fieldNames.append (string.lower(t[0]))
i = 0
dict = {}
for f in (rs):
- # TODO - There has got to be a better way
- if type(f) == type(1L):
- f = "%g" % f
dict[self._fieldNames[i]] = f
i = i + 1
self._cachedRecords.append (self._recordSetClass(parent=self, \
Index: gnue/gnue-common/src/dbdrivers/db2/DBdriver.py
diff -u gnue/gnue-common/src/dbdrivers/db2/DBdriver.py:1.4
gnue/gnue-common/src/dbdrivers/db2/DBdriver.py:1.5
--- gnue/gnue-common/src/dbdrivers/db2/DBdriver.py:1.4 Wed Aug 29 20:23:12 2001
+++ gnue/gnue-common/src/dbdrivers/db2/DBdriver.py Tue Sep 18 17:58:25 2001
@@ -58,50 +58,10 @@
cursor, defaultValues, masterRecordSet)
self._recordSetClass = DB2_RecordSet
-
- #### NOTE: Once PyGreSQL's .fetchone() bug is fixed, this method
- #### should be deleted! Also note the line in DB2_DataObject.__init__.
- #### Right now, we are having to preload *ALL* rows from a datasource.
- def _loadNextRecord(self):
- if self._cursor:
- try:
- rsall = self._cursor.fetchall()
- except self._DatabaseError, err:
- raise GDataObjects.ConnectionError, err
-
- if len(rsall):
- for rs in(rsall):
- GDebug.printMesg(5, "New row retrieved: %s" % rs)
- if not self._fieldNames:
- self._fieldNames = []
- for t in(self._cursor.description):
- self._fieldNames.append(t[0])
- self._boundFields[lower(t[0])] = ""
- GDebug.printMesg(5, "Field names set to %s" % self._fieldNames)
- if rs:
- i = 0
- dict = {}
- for f in(rs):
- dict[self._fieldNames[i]] = f
- i = i + 1
-
self._cachedRecords.append(self._recordSetClass(parent=self,initialData=dict))
- else:
- return 0
- return 1
- else:
- return 0
- else:
- return 0
-####
-
-
class DB2_DataObject(DBSIG_DataObject):
def __init__(self):
DBSIG_DataObject.__init__(self)
self._DatabaseError = "Database Error"
- #### When the PyGreSQL's .fetchone() bug is fixed, delete following line
- self._resultSetClass = DB2_ResultSet
-
def connect(self, connectData={}):
GDebug.printMesg(1,"DB2 database driver initializing")