~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/datasources/drivers/special/configfile/ResultSet.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# config/ResultSet.py
 
23
#
 
24
# DESCRIPTION:
 
25
# Implementation of dbdriver for use with configuration files
 
26
#
 
27
# NOTES and TODO:
 
28
#
 
29
# @see Connection.py
 
30
#
 
31
 
 
32
from gnue.common.datasources.drivers.Base.ResultSet import ResultSet
 
33
from RecordSet import Configfile_RecordSet
 
34
from gnue.common.apps import GDebug
 
35
 
 
36
#
 
37
# Configfile_ResultSet
 
38
#
 
39
class Configfile_ResultSet(ResultSet): 
 
40
  def __init__(self, dataObject, cursor=None, \
 
41
        defaultValues={}, masterRecordSet=None): 
 
42
    ResultSet.__init__(self, dataObject, cursor, defaultValues, masterRecordSet)
 
43
    self._recordSetClass = Configfile_RecordSet
 
44
    
 
45
    GDebug.printMesg(9, 'Configfile_ResultSet created')
 
46
 
 
47
 
 
48
  def _loadNextRecord(self):
 
49
    retval=0
 
50
    # all records has to be loaded in cache during resultset initialisation
 
51
    if self._cursor:
 
52
   
 
53
      # load all records at once  
 
54
      for dict in self._cursor:
 
55
            
 
56
        record=self._recordSetClass(parent=self,initialData=dict)
 
57
        self._cachedRecords.append (record)
 
58
 
 
59
        # increase record count by one
 
60
        self._recordCount=self._recordCount+1
 
61
 
 
62
        retval=1
 
63
        
 
64
      self._cursor=[] # after adding the values, delete them from cursor
 
65
      
 
66
    # if no record returned return a zero
 
67
    return retval