Ian,
Just wanted to thank you for posting this 'fix'.
I'm pretty new to both Python and TG and this problem was occurring in
the TG wiki tutorial.
I'm going to reference this thread as a comment in the tutorial to help
anyone else who runs into this.

Ian Wilson wrote:
> I am sorry.  Also I should actually start reading exception traces for
> once.  I think the problem is more of the data going IN than the data
> coming OUT.  I was doing a query like this:
> Plant.select(Plant.q.genus==searchWord) and it turns out searchWord
> was unicode.  And I don't know why it is unicode because I  stopped
> using a Unicode validator and starting using a regular String
> validator.
>
> So I think my problem is happening because of this:
> >>> unicode(unicode('', 'utf-8'),'utf-8')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: decoding Unicode is not supported
>
> AND because changing:
>                         myquery = unicode(query, self.encoding)
> To this:
>                     if type(query) != unicode:
>                         myquery = unicode(query, self.encoding)
>                     else:
>                         myquery = query
> in the file "sqlobject/mysql/mysqlconnection.py" fixes the problem.
>
> I really don't know if this is a "fix" or avoidance of the problem
> because my knowledge is minimal.    Thank you everyone for your
> responses sorry if my previuos posts were misleading and I am really
> confused but its working now.
>
> -Ian
>
> On 10/31/06, Max Ischenko <[EMAIL PROTECTED]> wrote:
> >
> >
> > Ian Wilson wrote:
> > > Yeah none of that seemed to work.   Any more ideas?
> >
> > I'm afraid we ran out of the decent ideas. Personally, I use the
> > following dburi and the patch included below to make it all work. IIRC
> > SQLObject developers even merged this patch into codebase but only in a
> > dev branch, not the stable version TG uses (and requires)
> >
> > sqlobject.dburi="mysql://...?client_encoding=utf8"
> >
> > Index: sqlobject/mysql/mysqlconnection.py
> > ===================================================================
> > --- sqlobject/mysql/mysqlconnection.py  (revision 1744)
> > +++ sqlobject/mysql/mysqlconnection.py  (working copy)
> > @@ -19,6 +19,10 @@
> >          self.user = user
> >          self.password = passwd
> >          self.kw = {}
> > +        if kw.has_key('client_encoding'):
> > +            self.client_encoding = col.popKey(kw, 'client_encoding')
> > +        else:
> > +            self.client_encoding = None
> >          for key in ("unix_socket", "init_command",
> >                  "read_default_file", "read_default_group"):
> >              if key in kw:
> > @@ -47,6 +51,8 @@
> >
> >          if hasattr(conn, 'autocommit'):
> >              conn.autocommit(bool(self.autoCommit))
> > +        if self.client_encoding:
> > +            conn.query('SET NAMES ' + self.client_encoding)
> >
> >          return conn
> >
> >
> > >
> >


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to