dabo Commit
Revision 2169
Date: 2006-05-17 10:33:12 -0700 (Wed, 17 May 2006)
Author: echo

Changed:
U   trunk/dabo/db/dBackend.py

Log:
Fixed an indenting with spaces.

Diff:
Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py   2006-05-17 17:32:14 UTC (rev 2168)
+++ trunk/dabo/db/dBackend.py   2006-05-17 17:33:12 UTC (rev 2169)
@@ -36,18 +36,18 @@
        def getConnection(self, connectInfo):
                """ override in subclasses """
                return None
-               
 
+
        def getDictCursorClass(self):
                """ override in subclasses """
                return None
-               
-       
+
+
        def getCursor(self, cursorClass):
                """ override in subclasses if necessary """
                return cursorClass(self._connection)
-       
-       
+
+
        def formatForQuery(self, val):
                if isinstance(val, (datetime.date, datetime.datetime)):
                        # Some databases have specific rules for formatting 
date values.
@@ -61,7 +61,7 @@
                elif val is None:
                        return self.formatNone()
                else:
-                       return self.escQuote(val)
+                       return self.escQuote(val)
 
 
        def formatDateTime(self, val):
@@ -72,16 +72,16 @@
                the default is to return the original value.
                """
                return val
-               
 
+
        def formatNone(self):
                """ Properly format a None value to be included in an update 
statement.
 
                Each backend should override as needed. The default is to 
return "NULL".
                """
                return "NULL"
-       
-       
+
+
        def noResultsOnSave(self):
                """ Most backends will return a non-zero number if there are 
updates.
                Some do not, so this will have to be customized in those cases.
@@ -94,13 +94,13 @@
                Some do not, so this will have to be customized in those cases.
                """
                raise dException.dException, _("No records deleted")
-               
-               
+
+
        def flush(self, cursor):
                """ Only used in some backends """
                return
-               
 
+
        def processFields(self, txt):
                """ Default is to return the string unchanged. Override
                in cases where the str needs processing.
@@ -111,26 +111,26 @@
        def escQuote(self, val):
                """ Escape special characters in SQL strings.
 
-               Escapes any single quotes that could cause SQL syntax errors, 
as well 
+               Escapes any single quotes that could cause SQL syntax errors, 
as well
                as any other characters which have special meanings with the 
backend
                database's engine.
                """
                # OVERRIDE IN SUBCLASSES!
                return val
-       
-       
+
+
        def getLastInsertID(self, cursor):
                """ Return the ID of the last inserted row, or None.
-               
+
                When inserting a new record in a table that auto-generates a PK
                value, different databases have their own way of retrieving 
that value.
                This method should be coded in backend-specific subclasses to 
address
                that database's approach.
-               """             
-               # Here is some code to fall back on if the specific subclass 
doesn't 
+               """
+               # Here is some code to fall back on if the specific subclass 
doesn't
                # override.
                try:
-                       # According to PEP-0249, it is common practice for a 
readonly 
+                       # According to PEP-0249, it is common practice for a 
readonly
                        # lastrowid attribute to be added by module authors, 
which will
                        # keep the last-insert id. This is by no means 
guaranteed, though.
                        # I've confirmed that it does work for MySQLdb.
@@ -141,22 +141,22 @@
 
        def getTables(self, includeSystemTables=False):
                """ Return a tuple of the tables in the current database.
-               
+
                Different backends will do this differently, so override in 
subclasses.
                """
                return tuple()
-               
-               
+
+
        def getTableRecordCount(self, tableName):
                """ Return the number of records in the backend table.
                """
                return -1
-       
-       
+
+
        def getFields(self, tableName):
                """ Return field information from the backend table.
-               
-               See dCursorMixin.getFields() for a description of the return 
value.                     
+
+               See dCursorMixin.getFields() for a description of the return 
value.
                """
                # It is too bad, but dbapi2.0's cursor().description doesn't 
cut it.
                # It will give the field names, but the type info and pk info 
isn't
@@ -180,37 +180,37 @@
 
        def getAutoCommitStatus(self, cursor):
                return self._autoCommit
-       
-       
+
+
        def setAutoCommitStatus(self, cursor, val):
                if hasattr(self._connection, "autocommit"):
                        self._connection.autocommit(val)
                        self._autoCommit = val
                else:
-                       # Without an autocommit method, assume 
+                       # Without an autocommit method, assume
                        # no autocommit.
                        self._autoCommit = False
-               
-       
+
+
        def beginTransaction(self, cursor):
                """ Begin a SQL transaction. Override in subclasses if 
needed."""
                pass
 
-               
+
        def commitTransaction(self, cursor):
                """ Commit a SQL transaction."""
                if not cursor.AutoCommit:
                        cursor.connection.commit()
 
-               
+
        def rollbackTransaction(self, cursor):
                """ Roll back (revert) a SQL transaction."""
                cursor.connection.rollback()
 
-               
+
        def addWithSep(self, base, new, sep=",\n\t"):
-               """ Convenient method of adding to an expression that 
-               may or may not have an existing value. If there is a value, 
+               """ Convenient method of adding to an expression that
+               may or may not have an existing value. If there is a value,
                the separator is inserted between the two.
                """
                if base:
@@ -218,8 +218,8 @@
                else:
                        ret = new
                return ret
-               
-               
+
+
        def addField(self, clause, exp):
                """ Add a field to the field clause."""
                return self.addWithSep(clause, exp)
@@ -228,34 +228,34 @@
        def addFrom(self, clause, exp):
                """ Add a table to the sql statement."""
                return self.addWithSep(clause, exp)
-               
 
+
        def addWhere(self, clause, exp, comp="and"):
                """ Add an expression to the where clause."""
                return self.addWithSep(clause, exp, sep=" %s " % comp)
-               
 
+
        def addGroupBy(self, clause, exp):
                """ Add an expression to the group-by clause."""
                return self.addWithSep(clause, exp)
-               
 
+
        def addOrderBy(self, clause, exp):
                """ Add an expression to the order-by clause."""
                return self.addWithSep(clause, exp)
-               
-               
+
+
        def getLimitWord(self):
                """ Return the word to use in the db-specific limit clause.
                Override for backends that don't use the word 'limit'
                """
                return "limit"
-       
-       
-       def formSQL(self, fieldClause, fromClause, 
+
+
+       def formSQL(self, fieldClause, fromClause,
                                whereClause, groupByClause, orderByClause, 
limitClause):
-               """ Creates the appropriate SQL for the backend, given all 
-               the required clauses. Some backends order these differently, so 
+               """ Creates the appropriate SQL for the backend, given all
+               the required clauses. Some backends order these differently, so
                they should override this method with their own ordering.
                """
                clauses =  (fieldClause, fromClause, whereClause, groupByClause,
@@ -269,15 +269,15 @@
                for specific backends.
                """
                return clause
-               
-               
+
+
        def getWordMatchFormat(self):
-               """ By default, will return the standard format for an 
+               """ By default, will return the standard format for an
                equality test. If search by words is available, the format
                must be implemented in each specific backend.
-               
-               The format must have the expressions %(table)s, %(field)s, 
-               and %(value)s, which will be replaced with the table, field, 
+
+               The format must have the expressions %(table)s, %(field)s,
+               and %(value)s, which will be replaced with the table, field,
                and value strings, respectively.
                """
                return " %(table)s.%(field)s = %(value)s "
@@ -287,40 +287,40 @@
                """ By default, the update SQL statement will be in the form of
                                        tablename.fieldname
                but some backends do no accept this syntax. If not, change
-               this method to return an empty string, or whatever should 
+               this method to return an empty string, or whatever should
                preceed the field name in an update statement.
                """
                return tbl + "."
-       
-       
+
+
        def getWhereTablePrefix(self, tbl):
                """ By default, the comparisons in the WHERE clauses of
                SQL statements will be in the form of
                                        tablename.fieldname
                but some backends do no accept this syntax. If not, change
-               this method to return an empty string, or whatever should 
+               this method to return an empty string, or whatever should
                preceed the field name in a comparison in the WHERE clause
                of an SQL statement.
                """
                return tbl + "."
-       
-       
+
+
        def massageDescription(self, cursor):
                """Some dbapi programs do strange things to the description.
-               In particular, kinterbasdb forces the field names to upper case 
-               if the field statement in the SQL that was executed contains an 
-               'as' expression. 
-               
-               This is called after every execute() by the cursor, since the 
+               In particular, kinterbasdb forces the field names to upper case
+               if the field statement in the SQL that was executed contains an
+               'as' expression.
+
+               This is called after every execute() by the cursor, since the
                description field is updated each time. By default, we simply
                copy it to the 'descriptionClean' attribute.
                """
                cursor.descriptionClean = cursor.description
-       
-       
+
+
        def  getDescription(self, cursor):
                """Normally, cursors should always be able to report their
-               description properly. However, some backends such as 
+               description properly. However, some backends such as
                SQLite will not report a description if there is no data in the
                record set. This method provides a way for those backends
                to deal with this. By default, though, just return the contents
@@ -331,15 +331,15 @@
                else:
                        return cursor.descriptionClean
 
-       
+
        def pregenPK(self, cursor):
-               """In the case where the database requires that PKs be 
generated 
-               before an insert, this method provides a backend-specific 
+               """In the case where the database requires that PKs be generated
+               before an insert, this method provides a backend-specific
                means of accomplishing this. By default, we return None.
                """
                return None
-       
-       
+
+
        def setNonUpdateFields(self, cursor):
                """Normally, this routine should work for all backends. But
                in the case of SQLite, the routine that grabs an empty cursor
@@ -365,24 +365,24 @@
                stdFlds = auxCrs.FieldDescription
 
                # Get all the fields that are not in the table.
-               cursor.__nonUpdateFields = [d[0] for d in descFlds 
+               cursor.__nonUpdateFields = [d[0] for d in descFlds
                                if d[0] not in [s[0] for s in stdFlds] ]
                # Extract the remaining fields (no need to test any already 
excluded
                remFlds = [ d for d in descFlds if d[0] not in 
cursor.__nonUpdateFields ]
-               
-               # Now add any for which the members (except the display value, 
+
+               # Now add any for which the members (except the display value,
                # which is in position 2) do not match
-               cursor.__nonUpdateFields += [ b[0] for b in remFlds 
+               cursor.__nonUpdateFields += [ b[0] for b in remFlds
                                for s in [z for z in stdFlds if z[0] == b[0] ]
-                               if (b[1] != s[1]) or (b[3] != s[3]) or (b[4] != 
s[4]) 
+                               if (b[1] != s[1]) or (b[3] != s[3]) or (b[4] != 
s[4])
                                or (b[5] != s[5]) or (b[6] != s[6]) ]
-               
-               
+
+
        def getStructureDescription(self, cursor):
                """This will work for most backends. However, SQLite doesn't
                properly return the structure when no records are returned.
                """
-               #Try using the no-records version of the SQL statement. 
+               #Try using the no-records version of the SQL statement.
                try:
                        tmpsql = cursor.getStructureOnlySql()
                except AttributeError:
@@ -397,19 +397,19 @@
                                pat = 
re.compile("(\s*select\s*.*\s*from\s*.*\s*)((?:group\s*by\s(.*))+)\s*", re.I | 
re.M | re.S)
                                if pat.search(cursor.sql):
                                        tmpsql = pat.sub("\\1 where 1=0 ", 
cursor.sql)
-                               else:               
+                               else:
                                        pat = 
re.compile("(\s*select\s*.*\s*from\s*.*\s*)((?:order\s*by\s(.*))+)\s*", re.I | 
re.M | re.S)
                                        if pat.search(cursor.sql):
                                                tmpsql = pat.sub("\\1 where 1=0 
", cursor.sql)
-                                       else:               
+                                       else:
                                                # Nothing. So just tack it on 
the end.
                                                tmpsql = cursor.sql + " where 
1=0 "
                auxCrs = cursor._getAuxCursor()
                auxCrs.execute(tmpsql)
                auxCrs.storeFieldTypes(cursor)
                return auxCrs.FieldDescription
-       
 
+
        ##########              Created by Echo         ##############
        def isExistingTable(self, table):
                """Returns whether or not the table exists."""
@@ -422,28 +422,28 @@
        def _isExistingTable(self, tablename):
                # OVERRIDE IN SUBCLASSES!
                return False
-               
-       
+
+
        def createJustTable(self, tabledef, cursor):
                self.createTableAndIndex(tabledef, cursor, createIndexes=False)
 
-               
+
        def createJustIndexes(self, tabledef, cursor):
                self.createTableAndIndexes(tabledef, cursor, createTable=False)
 
-       
-       def createTableAndIndexes(self, tabledef, cursor, createTable=True, 
+
+       def createTableAndIndexes(self, tabledef, cursor, createTable=True,
                        createIndex=True):
                """Creates a table and/or indexes based on the dTable passed to 
it."""
                # OVERRIDE IN SUBCLASSES!
-               pass            
+               pass
        ##########              END  - Created by Echo  ##############
 
-       
-       ###########################################     
-       # The following methods by default simply return the text 
+
+       ###########################################
+       # The following methods by default simply return the text
        # supplied to them. If a particular backend (Firebird comes
-       # to mind) has specific formatting requirements, though, 
+       # to mind) has specific formatting requirements, though,
        # that subclass should override these.
        def setSQL(self, sql):
                return sql
@@ -459,17 +459,17 @@
                return clause
        def setOrderByClause(self, clause):
                return clause
-       ###########################################     
+       ###########################################
 
        def _setEncoding(self, enc):
                """ Set backend encoding. Must be overridden in the subclass
                to notify database about proper charset conversion.
                """
                self._encoding = enc
-               
+
        def _getEncoding(self):
                """ Get backend encoding."""
                return self._encoding
 
-       Encoding = property(_getEncoding, _setEncoding, None, 
+       Encoding = property(_getEncoding, _setEncoding, None,
                        _("Backend encoding  (str)"))




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to