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

« back to all changes in this revision

Viewing changes to src/datasources/drivers/special/static/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 2001-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# _static/ResultSet.py
 
23
#
 
24
# DESCRIPTION:
 
25
# Virtual database driver for a connectionless, static set of data
 
26
#
 
27
# NOTES:
 
28
# Used whenever a fixed set of data is needed
 
29
#
 
30
 
 
31
__all__ = ["STATIC_ResultSet"]
 
32
 
 
33
from gnue.common.datasources.drivers import Base
 
34
from RecordSet import STATIC_RecordSet
 
35
 
 
36
class STATIC_ResultSet(Base.ResultSet):
 
37
 
 
38
  def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):
 
39
    Base.ResultSet.__init__(self, dataObject, \
 
40
            cursor, defaultValues, masterRecordSet)
 
41
    
 
42
    self._recordSetClass = STATIC_RecordSet
 
43
 
 
44
  # Returns 1=DataObject has uncommitted changes
 
45
  def isPending(self):
 
46
    return 0    # Static DataObjects cannot have pending changes :)
 
47
 
 
48
  # Post changes to the database
 
49
  def post(self):
 
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):
 
53
      record.post()
 
54
 
 
55
  # Load cacheCount number of new records
 
56
  def _loadNextRecord(self):
 
57
    if hasattr(self,"_alldataloaded"):
 
58
      return 0
 
59
    
 
60
    # Load static data
 
61
    for row in self._dataObject._staticSet._children:
 
62
      dict = {}
 
63
      for field in row._children:
 
64
        dict[field.name] = field.value
 
65
 
 
66
      record=self._recordSetClass(parent=self,initialData=dict)
 
67
      
 
68
      self._cachedRecords.append (record)
 
69
      
 
70
      self._recordCount=self._recordCount+1
 
71
 
 
72
    self._alldataloaded = 1
 
73
      
 
74
    return 1
 
75
 
 
76
 
 
77
  # Create an empty record
 
78
  def _createEmptyRecord(self, masterRecordSet=None): 
 
79
    return self._recordSetClass(self, None)