On Sun, Sep 10, 2006 at 04:16:12PM +0200, Markus Gritsch wrote:
> col.py:
>
> class UnicodeStringValidator(validators.Validator):
>
> def to_python(self, value, state):
> if value is None:
> return None
> if isinstance(value, unicode):
> return value
> if isinstance(value, array_type): # MySQL
> return unicode(value.tostring(), self.db_encoding)
> return unicode(value, self.db_encoding)
>
> If I print the type of the value, it says <type 'str'> which is IMO
> the problem. The
> if isinstance(value, unicode):
> line does therefore not match, and the last line of the method
> return unicode(value, self.db_encoding)
> is executed, which raises the exception. If I modify the last line to
> return value
> the value is inserted correctly into the database.
This is because from_python() has been called (in main.py, .set()) and
converted the value to a string.
> Note that since MySQLdb version 1.2.2b1 it is possible to use a
> unicode string as the query-string.
Yes, but SQLObject is not MySQL-only ORM, and hence uses strings
internally.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
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