/[papo]/gnue/common/src/dbdrivers/_static/DBdriver.py
ViewVC logotype

Diff of /gnue/common/src/dbdrivers/_static/DBdriver.py

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

revision 1.3 by charlie, Tue Aug 27 18:15:52 2002 UTC revision 1.4 by styxman, Fri Nov 15 15:32:55 2002 UTC
# Line 16  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2001 Free Software Foundation  # Copyright 2001-2002 Free Software Foundation
20  #  #
21  # FILE:  # FILE:
22  # _static/DBdriver.py  # _static/DBdriver.py
# Line 30  Line 30 
30    
31  from gnue.common import GDebug  from gnue.common import GDebug
32  import string  import string
33  from gnue.common.GDataObjects import *  from gnue.common.GDataObjects import *
34    
35    
36  ###########################################################  ###########################################################
# Line 40  from gnue.common.GDataObjects import * Line 40  from gnue.common.GDataObjects import *
40  ###########################################################  ###########################################################
41  class STATIC_DataObject (DataObject):  class STATIC_DataObject (DataObject):
42    
43    def __init__(self):    def __init__(self):
44      DataObject.__init__(self)      DataObject.__init__(self)
45      self.triggerExtensions = TriggerExtensions(self)      self.triggerExtensions = TriggerExtensions(self)
46    
47    def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):    
48      def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None, sql=""):
49      return STATIC_ResultSet(self, masterRecordSet=masterRecordSet)      return STATIC_ResultSet(self, masterRecordSet=masterRecordSet)
50    
51    # We don't do logins    # We don't do logins
52    def getLoginFields(self):    def getLoginFields(self):
53      return ()      return ()
54    
55    # We don't do connections (we are connectionless)    # We don't do connections (we are connectionless)
56    def connect(self, connectData={}):    def connect(self, connectData={}):
57        # build field list
58        self._fieldReferences=string.split(self._staticSet.fields,",")
59    
60      self._postConnect()      self._postConnect()
61    
62    # We don't do commits    # We don't do commits
# Line 67  class STATIC_DataObject (DataObject): Line 71  class STATIC_DataObject (DataObject):
71    
72  ###########################################################  ###########################################################
73  #  #
74  #  #
75  #  #
76  ###########################################################  ###########################################################
77  class STATIC_ResultSet(ResultSet):  class STATIC_ResultSet(ResultSet):
78    
79    def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):    def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None):
80      ResultSet.__init__(self, dataObject, \      ResultSet.__init__(self, dataObject, \
81              cursor, defaultValues, masterRecordSet)              cursor, defaultValues, masterRecordSet)
82        
83      self._recordSetClass = STATIC_RecordSet      self._recordSetClass = STATIC_RecordSet
84    
85      # Returns 1=DataObject has uncommitted changes
   # Returns 1=DataObject has uncommitted changes  
86    def isPending(self):    def isPending(self):
87      return 0    # Static DataObjects cannot have pending changes :)      return 0    # Static DataObjects cannot have pending changes :)
88    
# Line 86  class STATIC_ResultSet(ResultSet): Line 90  class STATIC_ResultSet(ResultSet):
90    def post(self):    def post(self):
91      # Leave this here in case (for some bizarro reason)      # Leave this here in case (for some bizarro reason)
92      # a bound dataobject uses us as a master      # a bound dataobject uses us as a master
93      for record in (self._cachedRecords):      for record in (self._cachedRecords):
94        record.post()        record.post()
95    
   # Returns 1=Field is bound to a database field  
   def isFieldBound(self, fieldName):  
     return 0  
   
96    # Load cacheCount number of new records    # Load cacheCount number of new records
97    def _loadNextRecord(self):    def _loadNextRecord(self):
98      return 0      if hasattr(self,"_alldataloaded"):
99          return 0
100        
101        # Load static data
102        for row in self._dataObject._staticSet._children:
103          dict = {}
104          for field in row._children:
105            dict[field.name] = field.value
106    
107          record=self._recordSetClass(parent=self,initialData=dict)
108          
109          self._cachedRecords.append (record)
110          
111          self._recordCount=self._recordCount+1
112    
113        self._alldataloaded = 1
114          
115        return 1
116    
117    
118    # Create an empty record    # Create an empty record
119    def _createEmptyRecord(self, masterRecordSet=None):    def _createEmptyRecord(self, masterRecordSet=None):
120      return self._recordSetClass(self, masterRecordSet=masterRecordSet)      return self._recordSetClass(self, None)
121    
122    
123  ###########################################################  ###########################################################
# Line 117  class STATIC_RecordSet (RecordSet): Line 134  class STATIC_RecordSet (RecordSet):
134    def _postChanges(self):    def _postChanges(self):
135      return 1      return 1
136    
137      
138    
139    
140    
141  #  #
# Line 130  class TriggerExtensions: Line 149  class TriggerExtensions:
149    
150  ######################################  ######################################
151  #  #
152  #  The following hashes describe  #  The following hashes describe
153  #  this driver's characteristings.  #  this driver's characteristings.
154  #  #
155  ######################################  ######################################
156    
157  #  #
158  #  All datasouce "types" and corresponding DataObject class  #  All datasouce "types" and corresponding DataObject class
159  #  #
160  supportedDataObjects = {  supportedDataObjects = {
161    'object': STATIC_DataObject    'static': STATIC_DataObject
162  }  }
163    
164    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26