Hello,

There is a problem with SQLObject and MySQL connnection encoding. When SQLObject connects to the database, the underlying code (MySQLdb, libmysql) sets the connection encoding from defaults (possibly my.cnf, depending on libmysql compile-time config). SQLobject *expects* UTF-8 and if the system's default is different, bad things happen. A quick and definitive fix to this I propose is to modify _executeRetry:

def _executeRetry(self, conn, cursor, query):
  while 1:
    try:
      cursor.execute('SET NAMES utf8')  # ADDED
      return cursor.execute(query)
    except MySQLdb.OperationalError, e:
      if e.args[0] == 2013: # SERVER_LOST error
        if self.debug:
        self.printDebug(conn, str(e), 'ERROR')
      else:
        raise

That will work on MySQL 4.1 and up and can be tweaked to work on 4.0 too. Supporting anything below is suicide anyway.

BTW the fix is against SQLObject-0.7rc1, I haven't checked trunk for any changes.



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to