[Mailman-Developers] "Orignal" MySQL Member Adaptor - 1.71

Mark Sapiro mark at msapiro.net
Thu Jan 8 01:40:37 CET 2009


Fil wrote:

>OK I get something working with the following:
>
>
>    def escape(self, value):
>        try:
>            b = unicode(value,'utf-8')
>        except:
>            try:
>                b = unicode(value,'latin-1')
>            except:
>                b = value
>        return unicode(MySQLdb.escape_string(b.encode('utf-8')),'utf-8')
>
>
>will try a little more and commit if it works


I'm not totally up on what you're doing here, but I assume that value
is something like the member's real name.

In this case I think you may want something like

>From Mailman import Utils
...
    def escape(self, value):
        lcset = Utils.GetCharSet(mlist.preferred_language)
        b = unicode(value, lcset)
        ...

I.e. text items relating to a list or a member are normally either
unicodes to begin with or they are encoded in the character set of the
list's preferred language.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Developers mailing list