David Cramer wrote:
> Why wouldn't you just do this in a middleware? A decorator, or a
> clean_X on forms would not handle every incoming request like he
> wants.

maybe i wasn't clear in my original response to Amit.. the thing is,
even a middleware cannot nicely solve it imho.. or at least i'm
not sure how..

the problem is that the GET/POST dictionaries of the HttpRequest
are dynamically calculated...

so i'd have to wrap the HttpRequest object into my own object, which 
would delegate everything into HttpRequest, except _get_get, _get_post, 
etc... and even so i'm not sure if i could wrap it in a good-enough way 
(not to mention view-code that maybe assumes that isinstance(request, 
HttpRequest) holds...)

another approach is to (in the middleware) modify the "inside" of the 
request (request.raw_post_data and request.environ['QUERY_STRING']), but 
even that would require that i copy the convert-get-post-data-to-unicode 
code from django. which seems to be quite ugly and can cause 
errors/incompatibilities in the future.

gabor


> 
> On Apr 10, 11:26 am, Gábor Farkas <[EMAIL PROTECTED]> wrote:
>> On Thu, Apr 10, 2008 at 06:44:35AM -0700, simonb wrote:
>>
>>> On Apr 10, 2:48 pm, Gábor Farkas <[EMAIL PROTECTED]> wrote:
>>>> hi,
>>>> would it be a good idea to add support to django to unicode-normalize
>>>> incoming get/post-data?
>>> class NormCharField(forms.CharField):
>>>     def clean(self, value):
>>>         value = super(NormCharField, self).clean(value)
>>>         return unicodedata.normalize('NFC',text)
>>> Or am I missing something...
>> the idea is nice, but what if i don't want to use forms for this?
>>
>> the point is,that in my opinion, 99% of all developers want to have
>> their unicode-data normalized, before they process it. (maybe they
>> don't know yet that they want it, but they want it :-)
>>
>> there's simply no need to be able to differentiate between NFC and NFD
>> strings except when you are writing an application especially for
>> unicode-related-work. if there are any other situations, please tell me.
>>
>> so, because the general case is the developer-does-not-care-about-it,
>> we should make it easy to do in django. imho, of course.
>>
>> gabor
> > 


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