Michael Radziej wrote:
> I'm not sure about what the last sentence means--are you suggesting to
> put #3370 (the mysql part) into "Needs design decision"?

## 3370

I'm -1 on setting MySQL connection to 'utf8' in #3370. It *will* make 
sense when we will have newforms ready and models containing unicode. 
But now most of Django is a byte string country. A bright example are 
generic views that take data from web and store it to models without any 
conversions. This patch will feed 'windows-1251' or 'iso-8859-1' to 
MySQL saying that "it's utf-8" and MySQL will try to convert it and most 
certainly will store just strings of '????'. The patch is working for 
the author only because it feeds newforms' unicode objects right into 
models which is wrong (we hadn't convert models to unicode yet).

But the __repr__ part is plain incorrect:

     try:
         return '<%s: %s>' % (self.__class__.__name__, self)
     except UnicodeEncodeError:
         return '<%s: %s>' % (self.__class__.__name__, 
self.__str__().encode(settings.DEFAULT_CHARSET))

The __str__().encode(...) is wrong because it's already 'str' and you 
can't encode it any further.

It was working for patch author because he had __str__ of a model 
returning a unicode object. It's wrong and it should be fixed after the 
whole unicodfication of Django. But patching it this way will break 
perfectly normal code where people don't assign unicode objects to model 
properties. Granted, the breakage won't be very bad because people don't 
show __repr__ to users often. But it's still bad.

## 952

This patch tries to set connection encoding to the one used for web: 
DEFAULT_CHARSET. But when we convert Django to unicode (we'll have to do 
it anyway because of newforms) this won't be necessary because models 
will be unicodified too. Then it'll make sense to set 'utf8' in all 
backends as a connection encoding.

## Suggestion

Now I think we should close all these bugs. Don't laugh (or cry)! #952 
is neither long-term nor helps ak's case, #3370 is broken (sorry, ak, 
but it is) and #1356 is a dupe of #3370.

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

Reply via email to