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

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

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

revision 1.1 by jcater, Fri Oct 10 01:21:10 2003 UTC revision 1.2 by jcater, Tue Nov 25 17:01:31 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    # _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__ = ['ResultSet']
35    
36    from gnue.common.datasources import GConditions, Exceptions
37    from gnue.common.datasources.drivers.Base import ResultSet as BaseResultSet
38    from gnue.common.apps import GDebug
39    import string
40    import types
41    
42    from RecordSet import RecordSet
43    
44    class ResultSet(BaseResultSet):
45      _recordSetClass = RecordSet
46      def __init__(self, *args, **parms):
47        BaseResultSet.__init__(self, *args, **parms)
48        self._fieldNames = []
49    
50        if self._cursor:
51          for t in(self._cursor.description):
52            self._fieldNames.append(t[0])
53          GDebug.printMesg(5, "Field names set to %s" % self._fieldNames)
54    
55        self._recordCount = self._cursor.rowcount or 0
56    
57        GDebug.printMesg(5, 'ResultSet created')
58    
59      def _loadNextRecord(self):
60        if self._cursor:
61          rs = None
62    
63          try:
64            rsets = self._cursor.fetchmany()
65          except self._dataObject._DatabaseError, err:
66            raise Exceptions.ConnectionError, err
67          if rsets and len(rsets):
68            for rs in(rsets):
69              if rs:
70                i = 0
71                dict = {}
72                for f in (rs):
73                  if self._dataObject._unicodeMode and type(f)==types.StringType:
74                    f = unicode(f,self._dataObject._connection._encoding)
75                    
76                  dict[string.lower(self._fieldNames[i])] = f
77                  i += 1
78                self._cachedRecords.append (self._recordSetClass(parent=self, \
79                                                                 initialData=dict))
80              else:
81                return 0
82            return 1
83          else:
84            # We no longer need the cursor if we are read only
85            if self._readonly:
86              self._cursor.close()
87            return 0
88        else:
89          return 0
90    

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