commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7469 - in trunk/gnue-common/src/datasources: . drivers/Base driv


From: reinhard
Subject: [gnue] r7469 - in trunk/gnue-common/src/datasources: . drivers/Base drivers/DBSIG2 drivers/appserver/appserver drivers/file
Date: Sat, 23 Apr 2005 06:54:42 -0500 (CDT)

Author: reinhard
Date: 2005-04-23 06:54:40 -0500 (Sat, 23 Apr 2005)
New Revision: 7469

Removed:
   trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
   trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
Modified:
   trunk/gnue-common/src/datasources/GConnections.py
   trunk/gnue-common/src/datasources/GDataSource.py
   trunk/gnue-common/src/datasources/drivers/Base/Connection.py
   trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
   trunk/gnue-common/src/datasources/drivers/Base/__init__.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/__init__.py
   trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
   trunk/gnue-common/src/datasources/drivers/appserver/appserver/__init__.py
   trunk/gnue-common/src/datasources/drivers/file/Base.py
Log:
Bye bye DataObject!


Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py   2005-04-23 10:04:00 UTC 
(rev 7468)
+++ trunk/gnue-common/src/datasources/GConnections.py   2005-04-23 11:54:40 UTC 
(rev 7469)
@@ -270,33 +270,7 @@
 
     return conn
 
-
   #
-  # Return a database provider object
-  #
-  def getDataObject(self, connection_name, connection_type, datasource = None):
-
-    # This will throw a GConnections.NotFoundError if an unknown
-    # connection name is specified.  The calling method should
-    # catch this exception and handle it properly (exit w/message)
-    connection = self.getConnection(connection_name)
-
-    try:
-      dd = connection.supportedDataObjects[connection_type](connection,
-          datasource)
-      gDebug (7, 'Attaching to %s (%s)' \
-          % (dd.__class__.__name__, connection_type))
-      return dd
-    except KeyError:
-      tmsg = u_("DB Driver '%(connection)s' does not support source type "
-                "'%(conType)s'") \
-             % {'connection': connection,
-                'conType': connection_type}
-      raise Exceptions.ObjectTypeNotAvailableError, tmsg
-
-
-
-  #
   # Has a connection been initialized/established?
   #
   # TODO: this was likely broken
@@ -304,23 +278,6 @@
     return self._openConnections.has_key(string.lower(connection))
 
 
-  #
-  # Get a data connection for a specified database
-  #
-  def requestConnection(self, dataObject):
-
-#   print """TODO: once this branch makes it into CVS head,
-#     eliminate the GConnections.requestConnection logic!"""
-
-    # Support for multiple open connections
-    # to same database.
-    # Specify as 'gnue:1', 'gnue:2', etc, to open
-    # two actual connections to 'gnue', each with
-    # their own transactions, etc.
-
-    self.loginToConnection(dataObject._connection)
-
-
   # ---------------------------------------------------------------------------
   # login to a connection
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py    2005-04-23 10:04:00 UTC 
(rev 7468)
+++ trunk/gnue-common/src/datasources/GDataSource.py    2005-04-23 11:54:40 UTC 
(rev 7469)
@@ -64,7 +64,6 @@
 
     self._connections = None
     self._connection = None             # GConnection object
-    self._dataObject = None
     self.__master = None                # Master DataSource object
     self._masterPkFields = []           # M/D link fields in the master table
     self._masterFkFields = []           # M/D link fields in the detail table
@@ -217,12 +216,52 @@
 
   def __primaryInit (self):
 
-    self._topObject = self.findParentOfType(self._toplevelParent)
-    gDebug (9, "Setting %s to connect mgr %s" \
-        % (self.name, self._topObject._connections))
-    self.setConnectionManager(self._topObject._connections)
-    self.initialize()
-    self.connect()
+    self._topObject = self.findParentOfType (self._toplevelParent)
+    self.setConnectionManager (self._topObject._connections)
+
+    if self.connection is None:
+      # For connectionless (unbound or static) datasources, the base driver is
+      # enough
+      from gnue.common.datasources.drivers import Base
+      self.__resultSetClass = Base.ResultSet
+    else:
+      # Get Connection object and log in
+      self._connection = self._connections.getConnection (self.connection,
+          login = True)
+
+      # Remember the result set class to use
+      self.__resultSetClass = self._connection._resultSetClass
+      
+      # Check if the connection has a fixed primary key name
+      primarykeyFields = self._connection._primarykeyFields
+      if primarykeyFields:
+        self._primarykeyFields = primarykeyFields
+        self.referenceFields (self._primarykeyFields)
+
+      # Include the rowid in list of field references
+      rowidField = self._connection._rowidField
+      if rowidField:
+        # TODO: checks if the rowid is available and should be used go here:
+        # 1. if primary key should be prefered, don't set self._rowidField
+        # 2. try if rowidField is available in current table/view
+        if not self._primarykeyFields:
+          self._rowidField = rowidField
+          self.referenceField (self._rowidField)
+
+    # Add ourselves into the "global" datasource dictionary
+    self._topObject._datasourceDictionary [self.name.lower ()] = self
+
+    # Check whether the type matches the used tags
+    if self.type == "sql" and self._rawSQL is None:
+      raise Exceptions.InvalidDatasourceDefintion, \
+        u_("Datasource %s is sql-based, but has no <sql> definition.") \
+        % self.name
+    elif not self.type == "sql" and self._rawSQL is not None:
+      raise Exceptions.InvalidDatasourceDefintion, \
+        u_("Datasource %s is not sql-based, but has a <sql> definition.") \
+        % self.name
+
+    # compatibility
     self.extensions = self._connection
 
 
@@ -292,68 +331,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Initialize the datasource
-  # ---------------------------------------------------------------------------
-
-  def initialize(self):
-
-    if self.connection is None:
-      # For connectionless (unbound or static) datasources, the base driver is
-      # enough
-      from gnue.common.datasources.drivers import Base
-      dataObject = Base.DataObject (None, self)
-      self.__resultSetClass = Base.ResultSet
-    else:
-      self.connection = string.lower(self.connection)
-      # This will throw a GConnections.NotFoundError if an unknown
-      # connection name is specified.  The calling method should
-      # catch this exception and handle it properly (exit w/message)
-      dataObject = \
-         self._connections.getDataObject (self.connection, self.type,
-             datasource = self)
-      self._connection = dataObject._connection
-      self.__resultSetClass = self._connection._resultSetClass
-      
-      # Check if the connection has a fixed primary key name
-      primarykeyFields = self._connection._primarykeyFields
-      if primarykeyFields:
-        self._primarykeyFields = primarykeyFields
-        self.referenceFields (self._primarykeyFields)
-
-      # Include the rowid in list of field references
-      rowidField = self._connection._rowidField
-      if rowidField:
-        # TODO: checks if the rowid is available and should be used go here:
-        # 1. if primary key should be prefered, don't set self._rowidField
-        # 2. try if rowidField is available in current table/view
-        if not self._primarykeyFields:
-          self._rowidField = rowidField
-          self.referenceField (self._rowidField)
-
-    self._topObject._datasourceDictionary [self.name.lower ()] = self
-
-    if self.type == "sql" and self._rawSQL is None:
-      raise Exceptions.InvalidDatasourceDefintion, \
-        u_("Datasource %s is sql-based, but has no <sql> definition.") \
-        % self.name
-    elif not self.type == "sql" and self._rawSQL is not None:
-      raise Exceptions.InvalidDatasourceDefintion, \
-        u_("Datasource %s is not sql-based, but has a <sql> definition.") \
-        % self.name
-
-    self._dataObject = dataObject
-
-
-  # ---------------------------------------------------------------------------
-  # Open a backend connection for this datasource
-  # ---------------------------------------------------------------------------
-
-  def connect(self):
-    if self.connection != None:
-      self._connections.requestConnection(self._dataObject)
-
-
-  # ---------------------------------------------------------------------------
   # Set the static condition for this datasource
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-common/src/datasources/drivers/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/Connection.py        
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/Base/Connection.py        
2005-04-23 11:54:40 UTC (rev 7469)
@@ -38,13 +38,12 @@
   This class must be subclassed by all database drivers. It represents a
   connection to the backend.
 
+  @cvar _resultSetClass: implementation of the ResultSet class to be used with
+    the connection.  Must be overwritten by descendants.
   @cvar defaultBehaviour: Standard schema introspector class for this type of
     connection.  Must be overwritten by descendants.
   @cvar defaultCreator: Standard schema creator class for this type of
     connection.  Must be overwritten by descendants.
-  @cvar supportedDataObjects: Dictionary of dataObject classes available for
-    this connection type, where the key is the type of the dataObject (can be
-    'object' or 'sql').  Must be overwritten by descendants.
   @cvar _rowidField: Field name of the rowid generated by the backend.  Can be
     overwritten by descendants if the backend supports rowids.
   @cvar _primarykeyFields: Field names of the primary key.  Can be overwritten
@@ -56,11 +55,10 @@
     for this connection.
   """
 
-  defaultBehaviour = None
-  defaultCreator   = None
-  supportedDataObjects = {}
-
-  _rowidField = None
+  _resultSetClass   = None
+  defaultBehaviour  = None
+  defaultCreator    = None
+  _rowidField       = None
   _primarykeyFields = None
 
 
@@ -68,7 +66,7 @@
   # Constructor
   # ---------------------------------------------------------------------------
 
-  def __init__(self, connections, name, parameters):
+  def __init__ (self, connections, name, parameters):
 
     self.manager = connections
     self.name = name

Deleted: trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/DataObject.py        
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/Base/DataObject.py        
2005-04-23 11:54:40 UTC (rev 7469)
@@ -1,28 +0,0 @@
-# GNU Enterprise Common Library - Base DB Driver - Data Object
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ['DataObject']
-
-class DataObject:
-  def __init__(self, connection, dataSource):
-    self._connection = connection

Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-23 
10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-23 
11:54:40 UTC (rev 7469)
@@ -178,7 +178,7 @@
 
   # ---------------------------------------------------------------------------
 
-  # Returns 1=DataObject has uncommitted changes
+  # Returns True if the current record has uncommitted changes
   def isRecordPending(self):
     return self.current.isPending()
 

Modified: trunk/gnue-common/src/datasources/drivers/Base/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/__init__.py  2005-04-23 
10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/Base/__init__.py  2005-04-23 
11:54:40 UTC (rev 7469)
@@ -29,6 +29,5 @@
 __noplugin__ = True
 
 from Connection import Connection
-from DataObject import DataObject
 from ResultSet import ResultSet
 from RecordSet import RecordSet

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-04-23 11:54:40 UTC (rev 7469)
@@ -33,8 +33,7 @@
 from gnue.common.datasources import Exceptions
 from gnue.common.datasources.drivers import Base
 
-import DataObject
-import ResultSet
+from ResultSet import ResultSet
 
 
 # =============================================================================
@@ -64,11 +63,8 @@
     sequence (True) or as mapping (False). Can be overwritten by descendants.
   """
 
-  _resultSetClass = ResultSet.ResultSet
+  _resultSetClass = ResultSet
 
-  supportedDataObjects = {'object': DataObject.DataObject_Object,
-                          'sql':    DataObject.DataObject_SQL}
-
   _drivername = None                    # DBSIG2 compatible driver module
   _boolean_false = False                # value to pass for boolean FALSE
   _boolean_true  = True                 # value to pass for boolean TRUE

Deleted: trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2005-04-23 11:54:40 UTC (rev 7469)
@@ -1,47 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2005 Free Software Foundation
-#
-# FILE:
-# DBSIG2/DataObject.py
-#
-# DESCRIPTION:
-"""
-Generic implementation of dbdriver using Python DB-SIG v2
-specification.
-"""
-#
-# NOTES:
-# The classes below are meant to be extended
-#
-# HISTORY:
-#
-
-__all__ = ['DataObject','DataObject_SQL','DataObject_Object']
-
-from gnue.common.datasources.drivers import Base
-
-class DataObject (Base.DataObject):
-  pass
-
-class DataObject_Object (DataObject):
-  pass
-
-class DataObject_SQL (DataObject):
-  pass

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/__init__.py        
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/__init__.py        
2005-04-23 11:54:40 UTC (rev 7469)
@@ -23,5 +23,4 @@
 __noplugin__ = True
 
 from Connection import *
-from DataObject import *
 from ResultSet import *

Modified: 
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py 
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py 
2005-04-23 11:54:40 UTC (rev 7469)
@@ -28,8 +28,7 @@
 from gnue.common.datasources.drivers import Base
 from gnue.common.rpc import client
 
-import DataObject
-import ResultSet
+from ResultSet import ResultSet
 
 from gnue.common.datasources.drivers.appserver.Schema.Discovery.Introspection 
import Introspection
 
@@ -43,12 +42,8 @@
   Connection class for GNUe-AppServer backends.
   """
 
-  _resultSetClass = ResultSet.ResultSet
-
-  defaultBehavior = Introspection
-
-  supportedDataObjects = {'object': DataObject.DataObject}
-
+  _resultSetClass   = ResultSet
+  defaultBehavior   = Introspection
   _primarykeyFields = [u'gnue_id']
 
 

Deleted: 
trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py 
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py 
2005-04-23 11:54:40 UTC (rev 7469)
@@ -1,36 +0,0 @@
-# GNU Enterprise Datasource Library - Driver for GNUe-AppServer
-#
-# Copyright 2000-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-from gnue.common.datasources.drivers import Base
-
-import ResultSet
-
-# =============================================================================
-# DataObject class
-# =============================================================================
-
-class DataObject (Base.DataObject):
-  """
-  Handles a dataobject in the GNUe-AppServer backend.
-  """
-  pass

Modified: 
trunk/gnue-common/src/datasources/drivers/appserver/appserver/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/__init__.py   
2005-04-23 10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/__init__.py   
2005-04-23 11:54:40 UTC (rev 7469)
@@ -26,5 +26,4 @@
 """
 
 from Connection import Connection
-from DataObject import DataObject
 from ResultSet import ResultSet

Modified: trunk/gnue-common/src/datasources/drivers/file/Base.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/Base.py      2005-04-23 
10:04:00 UTC (rev 7468)
+++ trunk/gnue-common/src/datasources/drivers/file/Base.py      2005-04-23 
11:54:40 UTC (rev 7469)
@@ -117,17 +117,6 @@
 
 
 # =============================================================================
-# DataObject class
-# =============================================================================
-
-class DataObject (Base.DataObject):
-  """
-  Generic DataObject class for file based backends.
-  """
-  pass
-
-
-# =============================================================================
 # Connection class
 # =============================================================================
 
@@ -137,12 +126,9 @@
   """
 
   _resultSetClass = ResultSet
-
   defaultBehavior = Introspection
 
-  supportedDataObjects = {'object': DataObject}
 
-
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]