commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7467 - in trunk/gnue-common/src/datasources: . drivers drivers/B


From: reinhard
Subject: [gnue] r7467 - in trunk/gnue-common/src/datasources: . drivers drivers/Base
Date: Fri, 22 Apr 2005 18:14:45 -0500 (CDT)

Author: reinhard
Date: 2005-04-22 18:14:44 -0500 (Fri, 22 Apr 2005)
New Revision: 7467

Removed:
   trunk/gnue-common/src/datasources/drivers/special/
Modified:
   trunk/gnue-common/src/datasources/GDataSource.py
   trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
Moved the remaining 3 lines of implementation of the static dbdriver into the
base dbdriver; this way no special dbdriver is necessary any more.


Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py    2005-04-22 22:56:39 UTC 
(rev 7466)
+++ trunk/gnue-common/src/datasources/GDataSource.py    2005-04-22 23:14:44 UTC 
(rev 7467)
@@ -206,7 +206,7 @@
 
 
   # ---------------------------------------------------------------------------
-  # Phase 1 init: Find connection object and open connection
+  # Phase 1 init: Find connection manager and open connection
   # ---------------------------------------------------------------------------
 
   def __primaryInit (self):
@@ -291,20 +291,12 @@
 
   def initialize(self):
 
-    if not self.connection:
-      # We are a connectionless datasource (virtual?)
-      # We have to bind to something, so bind to empty or static driver
-      if not self.type=="static":
-        from gnue.common.datasources.drivers import Base
-        gDebug (7, 'Using empty data driver')
-        dataObject = Base.DataObject (None, self)
-
-      else:
-        from gnue.common.datasources.drivers.special import static
-        gDebug (7, 'Using static data driver')
-        dataObject = static.DataObject (None, self)
-
-    elif self._connections:
+    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)
+    else:
       self.connection = string.lower(self.connection)
       # This will throw a GConnections.NotFoundError if an unknown
       # connection name is specified.  The calling method should
@@ -312,8 +304,6 @@
       dataObject = \
          self._connections.getDataObject (self.connection, self.type,
              datasource = self)
-      gDebug (7, "GDataSource.py bound to %s " % dataObject)
-
       self._connection = dataObject._connection
       
       # Check if the connection has a fixed primary key name

Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-22 
22:56:39 UTC (rev 7466)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-22 
23:14:44 UTC (rev 7467)
@@ -92,6 +92,8 @@
     self.__detailDataSources = detailDataSources
     self.__dataSource        = dataSource
 
+    self.__staticData = []              # Data for static datasources
+
     self._cachedRecords = []
     self._currentRecord = -1
     self._recordCount = 0
@@ -663,13 +665,24 @@
   # Virtual methods
   # ---------------------------------------------------------------------------
 
+  def _query_static (self, connection, data):
+    """
+    Execute a query.
+
+    Descendants would rather overwrite _query_object and/or _query_sql.
+    Parameters depend on the type of query (object/sql).
+    """
+    self.__staticData = data
+
+  # ---------------------------------------------------------------------------
+
   def _count (self):
     """
     Return the number of records returned by the query.
 
     @return: Number of records that will be yielded by @L{_fetch}.
     """
-    return 0
+    return len (self.__staticData)
 
   # ---------------------------------------------------------------------------
 
@@ -684,8 +697,8 @@
     communicate with the backend.
     @return: A generator for fieldname/value dictionaries.
     """
-    for record in []:
-      yield record
+    for row in self.__staticData:
+      yield row
 
   # ---------------------------------------------------------------------------
 





reply via email to

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