2
# This file is part of GNU Enterprise.
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.
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.
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.
19
# Copyright 2001-2005 Free Software Foundation
22
# _static/ResultSet.py
25
# Virtual database driver for a connectionless, static set of data
28
# Used whenever a fixed set of data is needed
31
__all__ = ["STATIC_ResultSet"]
33
from gnue.common.datasources.drivers import Base
34
from RecordSet import STATIC_RecordSet
36
class STATIC_ResultSet(Base.ResultSet):
38
def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):
39
Base.ResultSet.__init__(self, dataObject, \
40
cursor, defaultValues, masterRecordSet)
42
self._recordSetClass = STATIC_RecordSet
44
# Returns 1=DataObject has uncommitted changes
46
return 0 # Static DataObjects cannot have pending changes :)
48
# Post changes to the database
50
# Leave this here in case (for some bizarro reason)
51
# a bound dataobject uses us as a master
52
for record in (self._cachedRecords):
55
# Load cacheCount number of new records
56
def _loadNextRecord(self):
57
if hasattr(self,"_alldataloaded"):
61
for row in self._dataObject._staticSet._children:
63
for field in row._children:
64
dict[field.name] = field.value
66
record=self._recordSetClass(parent=self,initialData=dict)
68
self._cachedRecords.append (record)
70
self._recordCount=self._recordCount+1
72
self._alldataloaded = 1
77
# Create an empty record
78
def _createEmptyRecord(self, masterRecordSet=None):
79
return self._recordSetClass(self, None)