On Mon, Feb 25, 2008 at 3:03 PM, iain duncan <[EMAIL PROTECTED]> wrote:
> > Hi folks, I recently did a major upgrade on a site and moved it to a vps > that I'm maintaining, and now I seem to have lost all ability to enter > unicode. > > I'm using TG 1.0.4.3, SA 0.4.2p3, ToscaWidgets, and mysql. The server is > Ubuntu 6.06, python 2.4 > > I changed the default character set on mysql to utf8 and I changed the > character set on the database in question to utf8. My mysql settings > look like this now: > > mysql> show variables like 'character\_set\_%'; > +--------------------------+--------+ > | Variable_name | Value | > +--------------------------+--------+ > | character_set_client | utf8 | > | character_set_connection | utf8 | > | character_set_database | utf8 | > | character_set_filesystem | binary | > | character_set_results | utf8 | > | character_set_server | latin1 | > | character_set_system | utf8 | > +--------------------------+--------+ > > I have the following in my .cfg: > > sqlalchemy.convert_unicode = True > sqlalchemy.dburi="mysql://web:password/momcafe_dev" > > > My model has the fields in question declared as columns of type unicode, > and the widget uses a schema with UnicodeString validators. Here is an > extract of the widget is for good measure: > > # basic membership widget > class MemberProfileWidget( TableForm ): > engine_name = "genshi" > > > fields = [ > TextField( "business_name", label_text="Business Name: ", ), > TextField( "business_position", label_text="Title ", ), > TextArea( "business_description", label_text="Description: ", ), > ... > ] > > # using separate schema to allow password checks > class MemberProfileSchema(v.Schema): > filter_extra_fields = True > allow_extra_fields = True > > business_name = v.UnicodeString() > business_position = v.UnicodeString() > business_description = v.UnicodeString() > > validator = MemberProfileSchema() > > > Using the same type of code on a webfaction account with their mysql > setup, but without ToscaWidgets, I was having no problems with unicode > data being entered. Now if I try to enter unicode I get this traceback > from SA: > > (partial) > File > "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2p3-py2.4.egg/sqlalchemy/databases/mysql.py", > line 1472, in do_execute > cursor.execute(statement, parameters) > File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 137, in > execute > self.errorhandler(self, exc, value) > File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 33, > in defaulterrorhandler > raise errorclass, errorvalue > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 42: > ordinal not in range(128) > > > I'm at a loss as to how to proceed. Any help would be much appreciated, > it's causing serious problems right now! > Thanks > Iain > Iain, It looks like your encoding is set to ascii, rather than utf-8 someplace (my_guess_ is within sqlalchemy). Try setting the "encoding" or "charset" options that get passed to create_engine, and see if that helps You might also try setting the "assert_unicode" option to try and get more information about where things go off the rails. see: http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_options and: http://www.sqlalchemy.org/docs/04/sqlalchemy_databases_mysql.html (search for "latin1" in the first block of documentation) Those are about my only ideas...I don't use Unicode-friendly databases much, as most of my development is in in-house apps, where it isn't really a requirement. Kevin Horn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

