Gábor Farkas:
> but, if i understand correctly, you propose it to behave like:
> 
> 
> =============================
> filename1 = 
> request.POST.somehow_get_the_filename_i_do_not_want_to_look_it_up_right_now()
> 
> # let's pray that the user's html templates
> # are encoded using settings.DEFAULT_CHARSET
> 
> filename2 = filename1.decode(settings.DEFAULT_CHARSET)
> 
> filename3 = filename2.encode(sys.getfilesystemencoding())
> 
> f = open(filename3)
> =============================
> 
> which for me seems like a hack..., because:
> 
> 1. we do not mandate yet that GET/POST data is in settings.DEFAULT_CHARSET

We don't mandate any particular encoding in
settings.DEFAULT_CHARSET? Take a look at ticket #951 and the recent
discussion about it here. Generic views assume it, and the models
assume that every bytestring they get is in UTF-8, so we already
have conflicting assumptions (when DEFAULT_CHARSET is not UTF-8).
The mysql backends fails if the default connection encoding as set
up with the database server is different from UTF-8.

This will probably all be fixed to use DEFAULT_CHARSET or even
unicode instead of UTF-8, but does anybody currently successfully
use a different DEFAULT_CHARSET with the present Django.

> 2. generally playing these encode/decode games is not nice :)

You don't get around it. Sigh.

I particularly dislike what python is doing here.

You shouldn't be able to call unicode(bytestring) or str(unicode)
without giving an encoding, same for comparing unicode and
bytestrings. Just go through the open tickets in newforms to see
why. If you would have to fill in an encoding, it would be obvious
what to do. But as it is, it's much too easy to forget, and then you
get code that only works for ASCII, and since the test data also
only contains ASCII data (quite naturally, since using English for
test cases is just normal), the test suite doesn't find these bugs.

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to