/[gnue]/gnue-common/src/datasources/GDataObjects.py
ViewVC logotype

Diff of /gnue-common/src/datasources/GDataObjects.py

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

revision 1.72 by siesel, Tue Oct 7 13:02:51 2003 UTC revision 1.72.2.1 by jcater, Fri Oct 10 01:21:08 2003 UTC
# Line 85  class NoWriteSchemaSupport(Error): Line 85  class NoWriteSchemaSupport(Error):
85    # writing Schema to datasource    # writing Schema to datasource
86    pass    pass
87    
 class UnknownDataType(Error):  
   # raised when an unknown datatype is passed to the database  
   pass  
88    
89    
90  ###########################################################  ###########################################################
# Line 97  class UnknownDataType(Error): Line 94  class UnknownDataType(Error):
94  ###########################################################  ###########################################################
95  class DataObject:  class DataObject:
96    
97    def __init__(self):    def __init__(self, connection):
98      # Set by parser      self._connection = connection
99    
100      self.masterlink = ""      self.masterlink = ""
101      self.detaillink = ""      self.detaillink = ""
102    
# Line 115  class DataObject: Line 113  class DataObject:
113    
114      self._unboundFieldReferences = {}  # Contains names of all unbound      self._unboundFieldReferences = {}  # Contains names of all unbound
115                                         # field references                                         # field references
                                         
     self._databaseEncoding = 'iso8859-1'  # contain encoding used by database  
   
     try:  
       self._databaseEncoding = gConfig('textEncoding')  
     except:  
       pass  
   
     self._unicodeMode = 0  
116    
117      self._defaultValues = {}      self._defaultValues = {}
118      self.triggerExtensions = None  
119        # TODO: This is to keep old code from breaking.
120        # TODO: 0.5.1 was last version to support
121        # TODO triggerExtensions (functionality is now
122        # TODO: encapsulated in Connection objects.
123        self.triggerExtensions = connection
124    
125    # Do we have a master datasource?    # Do we have a master datasource?
126    def hasMaster(self):    def hasMaster(self):
# Line 191  class DataObject: Line 185  class DataObject:
185      self._detailObjects.append ([dataObject, handler])      self._detailObjects.append ([dataObject, handler])
186    
187    
   # Return a list of necessary login fields (e.g., user/pass).  
   # Each list item is another list of ["field label", isPassword?]  
   def getLoginFields(self):  
     return []  
   
   
   #  
   # Connect to database. Design to be replaced by vendor-specific code.  
   #  
   # NOTE: This will only be called for the FIRST dataobject  
   #   using a particular connection.  Any subsequent dataobjects  
   #   will only get setDataConnection() called. Therefore, any  
   #   routines that must be run for EACH dataobject after a connection  
   #   has been establisted should be placed in _postConnect(), not connect().  
   #  
   #   As such, if the vendor-specific drivers replace this method, the last  
   #   line of the new method should be self._postConnect()!  
   #  
   def connect(self, connectData={}):  
     self._postConnect()  
   
   
   #  
   # Post connection routines. Design to be replaced by vendor-specific code.  
   #  
   # NOTE: See note for connect()  
   #  
   def _postConnect(self):  
     pass  
   
   
188    #    #
189    # Set the associated data connection. Used by GConnections.    # Connect to database from a GConnection object
   # THERE IS NO NEED FOR VENDOR-CLASSES TO REPLACE THIS METHOD!  
190    #    #
191    # NOTE: See note for connect()    def connect(self):
192    #      self._dataConnection = self._connection.native
   def setDataConnection(self, connection):  
     self._dataConnection = connection  
193      self._postConnect()      self._postConnect()
194    
   
   def getDataConnection(self):  
     return self._dataConnection  
   
   
195    def commit(self):    def commit(self):
196      pass      pass
197    
# Line 248  class DataObject: Line 203  class DataObject:
203    # Schema (metadata) functions    # Schema (metadata) functions
204    #    #
205    
206    # Return a list of the types of Schema objects this driver provides    # TODO: DEPRECATED!!!!!
   # Contains tuples of (key, description, dataSource??)  
   # dataSource?? is true if this schema type can be a datasource  
207    def getSchemaTypes(self):    def getSchemaTypes(self):
208      return []      print "WARNING: Your app is calling GDataObject.getSchemaTypes()"
209        return self._connection.schema.types[:]
210    
211    # Return a list of Schema objects    # TODO: DEPRECATED!!!!!
212    def getSchemaList(self, type=None):    def getSchemaList(self, type=None):
213      return []      print "WARNING: Your app is calling GDataObject.getSchemaList()"
214        return self._connection.schema.find(type=type)
215    
216    # Find a schema object with specified name    # TODO: DEPRECATED!!!!!
217    def getSchemaByName(self, name, type=None):    def getSchemaByName(self, name, type=None):
218      return None      print "WARNING: Your app is calling GDataObject.getSchemaByName()"
219        return self._connection.schema.findfirst(name=name, type=type)
220    
221    
222    
   # write Schema to Database  
   def writeSchema(self,obj,overwrite=0):  
     tmsg = _("This database adapter doesn't have 'schema writing' support")  
     raise NoWriteSchemaSupport, tmsg  
223    
224    # Called when new record master in master/detail is queried    # Called when new record master in master/detail is queried
225    def _masterRecordChanged(self, master):    def _masterRecordChanged(self, master):

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.72.2.1

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