[Zope3-dev] Suspected bug in package mysqldbda-1.0.0.tgz for Zope 3

hoon kim kimhoon08 at hotmail.com
Sat Apr 16 06:47:36 EDT 2005


Hi all,

I'm a newbie and just installed the zope3 package on windows. I'm writing 
because i believe there is a bug in the mysqlda adaptor add-in package.

My configuration is as follows:
* OS = Windows XP Professional SP2
* Python Version = Python-2.3.5.exe
* Zope Version = ZopeX3-3.0.0.win32-py2.3.exe
* MySQL-Python adaptor = MySQL-python.exe-1.0.0.win32-my4.1-py2.3.exe
* Zope MySQL Package = mysqldbda-1.0.0.tgz
* MySQL Version =  mysql-4.1.10-win32.zip

I followed the installation instructions but when i tried to test the db 
connection through the web interface of zope 3, the following error was 
returned:

unknown encoding: latin1_swedish_ci

After reviewing the code, i found a way to correct the problem. I modified 
the package's adaptor.py package. The exact class modified was 
MySQLStringConverter.

Before:
class MySQLStringConverter:
    def __init__(self, encoding):
        self.encoding = encoding

    def __call__(self, string):
        if isinstance(string, str):
            return string.decode(self.encoding)
        elif isinstance(string, unicode):
            return string
        else:
            return string

After:
class MySQLStringConverter:
    def __init__(self, encoding):
        self.encoding = encoding

    def __call__(self, string):
        if isinstance(string, str):
            return string
        elif isinstance(string, unicode):
            return string
        else:
            return string

In other words i believe the error occurs when a string decode method is 
attempted. Thus the hack i did to fix it was to just return the string value 
instead and it seems to work fine now.

My purpose in writing is:
a) To notify the developers of this add-in of the possible bug
b) To see if anyone has a more elegant solution. Being new, i'm 99% my 
workaround is a very yucky hack and doesn't solve the problem in a elegant 
manner.

Rgds, HK




More information about the Zope3-dev mailing list