ak wrote:
> Could someone please explain me what was a problem with unicode support
> in oldforms so newforms have been made with unicode inside ?

I can! The thing is it has absolutely nothing to do with forms, it's 
just historical coincidence.

Originally Django was written with using byte strings everywhere and 
there were no such thing as "conversion problem". However there were 
problems with incorrect string operations on byte strings (maxlength 
counting, upper/lower casing, etc.) Some time ago there was a decision 
to convert Django to work internally with unicode strings and convert 
them into byte strings on boundaries to the web and to the database. And 
there were no such thing as newforms at that moment.

And then Adrian started to implement newforms and he has chosen to do 
its internal in unicode, for compatibility with Django's future as I 
understand it.

> Kick me if I wrong but what is a real reason to convert bytes back and
> forth ? Religion ?

Reasons are purely technical... I'll list them but please do read until 
the end of the letter before you disagree. I believe you just 
misunderstand some things about unicode.

1. Unicode is a universal encoding that can store all characters. 
Without universal encoding an app written by a Russian programmer 
wouldn't be able to use a library written by a French programmer. This 
is why we need unicode.

2. In Python unicode strings can be either 'unicode' objects or 
byte-strings encoded in utf-8. The problem with utf-8 is that you can't 
string operations with it. For example you can't cut a month's name to 3 
letter just by doing month[0:3] because letters can occupy different 
count of bytes. This is what unicode objects are for and why Django 
internally should work with unicode.

May I recommend you my post about unicode and bytes (it's in russian): 
http://softwaremaniacs.org/blog/2006/07/28/unicode-and-bytes/

> I agree with everyone who says that unicode is a
> must and 'legacy' charsets are crap but guys I already have a BIG
> application that was about 80% migrated from other python frameworks to
> django some time ago and for legacy reasons it was all in national
> charset, not unicode.

What gives you an idea that Django won't work with this data? All this 
unicode stuff is purely internal. If you want your app to output 
windows-1251, set DEFAULT_CHARSET to windows-1251 and data would be 
automatically converted from and to it. I believe even newforms already 
use this setting to convert unicode data for templates (if not it should 
be just fixed and I'm happy to make a patch since I got some free time).

> Then I found that oldforms support will be
> dropped soon or later. So we at here have decided to start moving (yes,
> moving again !!!) all our code to newforms and what we got ? We got
> that we now have to recode everything to utf-8

Sure not :-). I'd say it would be wise thing to do *eventually*. But for 
now you absolutely can keep your templates and python sources in 
windows-1251.

> Did anyone who used unicode with oldform has any problems ? I am sure
> noone did.

In fact nobody used unicode with old forms. All things in request.POST, 
manipulator.flatten_data and in db models were always in byte strings 
(except db models with psycopg2).

And there were problems with it. They were just fixed very early (a 
couple of them by yours truly).

> So guys please explain me what was a reason to make me to migrate to
> unicode ?

I still think that you're confusing migrating Django internals to 
unicode objects and converting your files to utf-8. It's not about the 
latter.

> My opinion is simple: let's decide once ether django is for unicode or
> django supports both unicode and national charsets and then let's work.

Sure Django does and will support national charsets. This is why we have 
DEFAULT_CHARSET setting. Internal unicode just lets Django have all the 
encode/decode stuff localized in two places instead of littered all over 
the code.

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