Author: reinhard Date: 2010-05-26 06:19:44 -0500 (Wed, 26 May 2010) New Revision: 10187
Modified: trunk/gnue-common/ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Base.py Log: SQLite allows for passing Unicode directly to the backend, and with Python 2.6, it even *requires* doing so. Property changes on: trunk/gnue-common ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2010-05-25 16:50:35.644000053 +0200 committer: Reinhard Müller <reinhard.muel...@bytewise.at> properties: branch-nick: common + timestamp: 2010-05-26 13:17:38.683000088 +0200 committer: Reinhard Müller <reinhard.muel...@bytewise.at> properties: branch-nick: common Name: bzr:file-ids - src/datasources/drivers/Base/ResultSet.py 4...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:src%2Fdatasources%2Fdrivers%2FBase%2FResultSet.py + src/datasources/drivers/DBSIG2/Connection.py 4...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:src%2Fdatasources%2Fdrivers%2FDBSIG2%2FConnection.py src/datasources/drivers/DBSIG2/ResultSet.py 4...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:src%2Fdatasources%2Fdrivers%2FDBSIG2%2FResultSet.py src/datasources/drivers/sql/sqlite3/Base.py 9...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:src%2Fdatasources%2Fdrivers%2Fsql%2Fsqlite3%2FBase.py Name: bzr:revision-id:v4 - 3116 reinhard.muel...@bytewise.at-20100426083315-ccfwx2pihuvqn60z 3117 reinhard.muel...@bytewise.at-20100503114756-unpxm52de0towufo 3118 reinhard.muel...@bytewise.at-20100503115129-uvondrz5bvkqubyv 3119 reinhard.muel...@bytewise.at-20100505081835-9peco6k7a2le0mvg 3120 reinhard.muel...@bytewise.at-20100505084742-wn5vtc4a129z8g28 3121 reinhard.muel...@bytewise.at-20100505092131-m2avvsci5w6aj0rv 3122 reinhard.muel...@bytewise.at-20100519151545-pybk8q2s234vzsf2 3123 reinhard.muel...@bytewise.at-20100525101023-xs7k6pkghh9t6fc3 3124 reinhard.muel...@bytewise.at-20100525114015-rj7eb0xdheqkcuql 3125 reinhard.muel...@bytewise.at-20100525145035-j177jbvu10me4mfp + 3116 reinhard.muel...@bytewise.at-20100426083315-ccfwx2pihuvqn60z 3117 reinhard.muel...@bytewise.at-20100503114756-unpxm52de0towufo 3118 reinhard.muel...@bytewise.at-20100503115129-uvondrz5bvkqubyv 3119 reinhard.muel...@bytewise.at-20100505081835-9peco6k7a2le0mvg 3120 reinhard.muel...@bytewise.at-20100505084742-wn5vtc4a129z8g28 3121 reinhard.muel...@bytewise.at-20100505092131-m2avvsci5w6aj0rv 3122 reinhard.muel...@bytewise.at-20100519151545-pybk8q2s234vzsf2 3123 reinhard.muel...@bytewise.at-20100525101023-xs7k6pkghh9t6fc3 3124 reinhard.muel...@bytewise.at-20100525114015-rj7eb0xdheqkcuql 3125 reinhard.muel...@bytewise.at-20100525145035-j177jbvu10me4mfp 3126 reinhard.muel...@bytewise.at-20100526111738-ic0wot9z1ulg2y1a Name: bzr:text-parents - src/datasources/drivers/Base/ResultSet.py svn-v3-single1-dHJ1bmsvZ251ZS1jb21tb24.:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:9973 + src/datasources/drivers/DBSIG2/Connection.py svn-v3-single1-dHJ1bmsvZ251ZS1jb21tb24.:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:9954 src/datasources/drivers/DBSIG2/ResultSet.py reinhard.muel...@bytewise.at-20100525114015-rj7eb0xdheqkcuql src/datasources/drivers/sql/sqlite3/Base.py svn-v3-single1-dHJ1bmsvZ251ZS1jb21tb24.:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-common:9954 Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py =================================================================== --- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py 2010-05-25 14:56:57 UTC (rev 10186) +++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py 2010-05-26 11:19:44 UTC (rev 10187) @@ -94,7 +94,9 @@ _named_as_sequence_ = False # Pass 'named' parameters as sequence _std_datetime_ = False + _unicode_ = False # Accepts Unicode strings + # --------------------------------------------------------------------------- # Constructor # --------------------------------------------------------------------------- @@ -106,10 +108,11 @@ self._driver = __import__ (self._drivername_, None, None, '*') # Encoding used to communicate with the database (not used by all drivers) - if parameters.has_key ('encoding'): - self._encoding = parameters ['encoding'] - else: - self._encoding = 'utf-8' + if not self._unicode_: + if parameters.has_key ('encoding'): + self._encoding = parameters ['encoding'] + else: + self._encoding = 'utf-8' self._native = None @@ -178,7 +181,7 @@ row = rows [0] result = {} for i in range (len (fields)): - if isinstance (row [i], str): + if not self._unicode_ and isinstance (row [i], str): result [fields [i]] = unicode (row [i], self._encoding) else: result [fields [i]] = row [i] @@ -334,7 +337,7 @@ # checktype (parameters_value, .....) -- too many valid types :-) # Convert to encoded string for database - if isinstance (statement, unicode): + if not self._unicode_ and isinstance (statement, unicode): s = statement.encode (self._encoding) else: s = statement @@ -343,7 +346,7 @@ # convert parameter dictionary to encoded strings p = {} for (key, value) in parameters.items (): - if isinstance (key, unicode): + if not self._unicode_ and isinstance (key, unicode): k = key.encode (self._encoding) else: k = key @@ -385,7 +388,7 @@ Descendants may override this function to to different type conversions. """ - if isinstance (value, unicode): + if not self._unicode_ and isinstance (value, unicode): # Unicode: return encoded string return value.encode (self._encoding) Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py =================================================================== --- trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py 2010-05-25 14:56:57 UTC (rev 10186) +++ trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py 2010-05-26 11:19:44 UTC (rev 10187) @@ -156,8 +156,11 @@ self.__connection = connection # get field names from cursor description - self.__fieldnames = [(unicode (d [0], connection._encoding)).lower () \ - for d in self.__cursor.description] + if connection._unicode_: + self.__fieldnames = [d[0].lower() for d in self.__cursor.description] + else: + self.__fieldnames = [(unicode (d [0], connection._encoding)).lower () \ + for d in self.__cursor.description] # --------------------------------------------------------------------------- @@ -197,7 +200,7 @@ for row in rows: result = {} for (fieldname, value) in zip (self.__fieldnames, row): - if isinstance (value, str): + if not self.__connection._unicode_ and isinstance (value, str): value = unicode (value, self.__connection._encoding) result [fieldname] = value yield result Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Base.py =================================================================== --- trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Base.py 2010-05-25 14:56:57 UTC (rev 10186) +++ trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Base.py 2010-05-26 11:19:44 UTC (rev 10187) @@ -52,6 +52,7 @@ _rowidField_ = u'oid' _broken_rowcount_ = True _must_fetchall_ = True + _unicode_ = True # --------------------------------------------------------------------------- _______________________________________________ commit-gnue mailing list commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue