On Tue, Nov 27, 2007 at 11:01:04PM +0300, Oleg Broytmann wrote:
> I have to fix the parameter

   Like in the attached patch.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.
Index: mysqlconnection.py
===================================================================
--- mysqlconnection.py  (revision 3162)
+++ mysqlconnection.py  (working copy)
@@ -1,5 +1,6 @@
-from sqlobject.dbconnection import DBAPI
 from sqlobject import col
+from sqlobject.dbconnection import DBAPI
+from sqlobject.main import deprecated
 MySQLdb = None
 
 class MySQLConnection(DBAPI):
@@ -11,7 +12,7 @@
     def __init__(self, db, user, passwd='', host='localhost', port=None, **kw):
         global MySQLdb
         if MySQLdb is None:
-            import MySQLdb, MySQLdb.constants.CR, MySQLdb.constants.ER
+            import MySQLdb
         self.module = MySQLdb
         self.host = host
         self.port = port
@@ -19,10 +20,6 @@
         self.user = user
         self.password = passwd
         self.kw = {}
-        if MySQLdb.version_info[:3] >= (1, 2, 1):
-            self.need_unicode = True
-        else:
-            self.need_unicode = False
         for key in ("unix_socket", "init_command",
                 "read_default_file", "read_default_group"):
             if key in kw:
@@ -36,9 +33,8 @@
         else:
             self.dbEncoding = None
         if "sqlobject_encoding" in kw:
-            self.encoding = col.popKey(kw, "sqlobject_encoding")
-        else:
-            self.encoding = 'ascii'
+            del kw["sqlobject_encoding"]
+            deprecated("sqlobject_encoding is deprecated and no longer used.")
         DBAPI.__init__(self, **kw)
 
     def connectionFromURI(cls, uri):
@@ -70,12 +66,12 @@
         if hasattr(conn, 'autocommit'):
             conn.autocommit(bool(self.autoCommit))
 
-        if self.dbEncoding:
+        if dbEncoding:
             if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
-                conn.set_character_set(self.dbEncoding)
+                conn.set_character_set(dbEncoding)
             else: # pre MySQLdb 1.2.1
                 # works along with monkeypatching code above
-                conn.query("SET NAMES %s" % self.dbEncoding)
+                conn.query("SET NAMES %s" % dbEncoding)
 
         return conn
 
@@ -86,13 +82,6 @@
     def _executeRetry(self, conn, cursor, query):
         while 1:
             try:
-                # For MySQLdb 1.2.1 and later, we go
-                # encoding->unicode->charset (in the mysql db)
-                if self.need_unicode and not isinstance(query, unicode):
-                    try:
-                        query = unicode(query, self.encoding)
-                    except UnicodeError:
-                        pass                        
                 return cursor.execute(query)
             except MySQLdb.OperationalError, e:
                 if e.args[0] == 2013: # SERVER_LOST error
@@ -174,10 +163,10 @@
                 colClass = col.UnicodeCol
             kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
             kw['dbName'] = field
-            
+
             # Since MySQL 5.0, 'NO' is returned in the NULL column (SQLObject 
expected '')
             kw['notNone'] = (nullAllowed.upper() != 'YES' and True or False)
-            
+
             if default and t.startswith('int'):
                 kw['default'] = int(default)
             elif default and t.startswith('float'):
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to