Oleg,

I am looking in svn at col.py, it seems that from_python in the
StringValidator class still uses ascii encoding exclusivly:

class StringValidator(validators.Validator):

    def to_python(self, value, state):
        if value is None:
            return None
        if isinstance(value, unicode):
            connection = state.soObject._connection
            dbEncoding = getattr(connection, "dbEncoding", None) or "ascii"
            return value.encode(dbEncoding)
        return value

    def from_python(self, value, state):
        if value is None:
            return None
        if isinstance(value, str):
            return value
        if isinstance(value, unicode):
-->            return value.encode("ascii")
        return value


Maybe I should not be getting there but I am. I am sure mysqld is set
to utf8 and the connection
is defaulted to utf8 as well.

Thanks

 Glenn



On Jan 4, 2008 4:21 PM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:

> Please, do not top-post.
>
> On Fri, Jan 04, 2008 at 04:15:09PM -0500, Glenn MacGregor wrote:
> > Looking into this issue a bit more revealed that in the StringValidator
> > class, line 505 on col.py, the from_python function tries to encode all
> > unicode type strings to ascii. Is this correct behavior? If so how can I
> get
> > around it ?
>
>   What version of SQLObject? In the latest version the encoding is not
> 'ascii' - the code is
>
>            dbEncoding = getattr(connection, "dbEncoding", None) or "ascii"
>
>   so to change the encoding (on MySQL) you have to set it in the DB URI:
>
> mysql://host:port/database?charset=utf-8
>                           ^^^^^^^^^^^^^
>
> Oleg.
> --
>     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
>           Programmers don't die, they just GOSUB without RETURN.
>
> -------------------------------------------------------------------------
> 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
>
-------------------------------------------------------------------------
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