commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7786 - trunk/gnue-common/src/datasources/drivers/DBSIG2


From: reinhard
Subject: [gnue] r7786 - trunk/gnue-common/src/datasources/drivers/DBSIG2
Date: Fri, 5 Aug 2005 05:16:08 -0500 (CDT)

Author: reinhard
Date: 2005-08-05 05:16:07 -0500 (Fri, 05 Aug 2005)
New Revision: 7786

Modified:
   trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py
Log:
Cleanup, docstrings, comments.


Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py       
2005-08-05 10:02:54 UTC (rev 7785)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py       
2005-08-05 10:16:07 UTC (rev 7786)
@@ -21,6 +21,10 @@
 #
 # $Id$
 
+"""
+Generic ResultSet class for DBSIG2 based database driver plugins.
+"""
+
 __all__ = ['ResultSet']
 
 from gnue.common.apps import errors
@@ -32,6 +36,11 @@
 # =============================================================================
 
 class InvalidRowCountError (errors.SystemError):
+  """
+  DBSIG2 module returned invalid row count. Probably _broken_rowcount_ should
+  be set in this driver.
+  """
+
   def __init__ (self, drivername, value):
     msg = u_("The driver '%(driver)s' returned an invalid row " \
              "count '%(count)s'") \
@@ -50,6 +59,44 @@
   """
 
   # ---------------------------------------------------------------------------
+  # Execute query for object type datasources
+  # ---------------------------------------------------------------------------
+
+  def _query_object_ (self, connection, table, fieldnames, condition,
+      sortorder, distinct):
+
+    params = {}
+    what = ', '.join (fieldnames)
+    if distinct:
+      what = 'DISTINCT ' + what
+    where = condition.asSQL (params)
+
+    # If the connection has a broken row count, query for the number of records
+    # first. This avoids conflicts with some drivers not supporting multiple
+    # open cursors (like adodbapi).
+    if connection._broken_rowcount_:
+      if distinct:
+        self.__count = 0
+      else:
+        query = self.__buildQueryCount (table, where)
+        self.__count = connection.sql1 (query, params)
+
+    query = self.__buildQuery (table, what, where, sortorder)
+    self.__cursor = connection.makecursor (query, params)
+
+    if not connection._broken_rowcount_:
+      self.__count = self.__cursor.rowcount
+
+    # If the driver has a broken rowcount, but does not report it as broken,
+    # protect clients from behaving very strange
+    if self.__count is None or self.__count < 0:
+      raise InvalidRowCountError, (connection._drivername_, self.__count)
+
+    self.__connection = connection
+    self.__fieldnames = fieldnames
+
+
+  # ---------------------------------------------------------------------------
   # Build the query string
   # ---------------------------------------------------------------------------
 
@@ -90,44 +137,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Execute query for object type datasources
-  # ---------------------------------------------------------------------------
-
-  def _query_object_ (self, connection, table, fieldnames, condition,
-      sortorder, distinct):
-
-    params = {}
-    what = ', '.join (fieldnames)
-    if distinct:
-      what = 'DISTINCT ' + what
-    where = condition.asSQL (params)
-
-    # If the connection has a broken row count, query for the number of records
-    # first. This avoids conflicts with some drivers not supporting multiple
-    # open cursors (like adodbapi).
-    if connection._broken_rowcount_:
-      if distinct:
-        self.__count = 0
-      else:
-        query = self.__buildQueryCount (table, where)
-        self.__count = connection.sql1 (query, params)
-
-    query = self.__buildQuery (table, what, where, sortorder)
-    self.__cursor = connection.makecursor (query, params)
-
-    if not connection._broken_rowcount_:
-      self.__count = self.__cursor.rowcount
-
-    # If the driver has a broken rowcount, but does not report it as broken,
-    # protect clients from behaving very strange
-    if self.__count is None or self.__count < 0:
-      raise InvalidRowCountError, (connection._drivername_, self.__count)
-
-    self.__connection = connection
-    self.__fieldnames = fieldnames
-
-
-  # ---------------------------------------------------------------------------
   # Execute query for SQL type datasources
   # ---------------------------------------------------------------------------
 
@@ -146,6 +155,7 @@
     self.__fieldnames = [(unicode (d [0], connection._encoding)).lower () \
                          for d in self.__cursor.description]
 
+
   # ---------------------------------------------------------------------------
   # Return result count
   # ---------------------------------------------------------------------------





reply via email to

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