iain duncan 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!

The MySQL database URLs require charset=utf8 as well:

 > sqlalchemy.dburi="mysql://web:password/momcafe_dev?charset=utf8"

The driver doesn't seem to detect the connection character set well and 
needs a hint.  From the traceback, it looks like the driver thinks the 
connection should be ascii.


--~--~---------~--~----~------------~-------~--~----~
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