Adrian Holovaty wrote: > On 6/17/06, James Bennett <[EMAIL PROTECTED]> wrote: >> I'm not convinced that it'd be a good thing to have request.POST >> evaluate to True in these cases, but the reasoning is somewhat >> pedantic. >> >> First and foremost, there's a logical difference between the request >> method and the request parameters, so it makes sense that a test for >> the method could evaluate to True while a test for the parameters >> could evaluate to False. >> >> Second, since request.POST is supposed to be a "dictionary-like" >> object, this would be unintuitive and, dare I say, "magical" behavior >> -- an empty dictionary is False. > > I agree 100% with James on this one. Having request.POST be an empty > dictionary evaluating to True -- that's just too odd. I think we ought > to bite the bullet and add request.method, which would be a shortcut > to a normalized (all caps?) version of request.META['REQUEST_METHOD'], > which is cumbersome to type and might not (?) always be upper case. >
i think the problem here is that we're mixing two things: 1. the method 2. the sent data for GET requests it's simple, because the sent data is in the querystring, so for GET requests the GET dictionary will contain the relevant data. but a POST request is more complicated. here you can do something like: <form action="http://127.0.0.1:8000/foo/?query=string" method="post"> <input type="text" name="first" value="1st"/> <input type="text" name="second" value ="2nd"/> <input type="submit" name="submit"> </form> and django will get (correctly): POST <MultiValueDict: {'second': ['2nd'], 'submit': ['Submit'], 'first': ['1st']}> GET <MultiValueDict: {'query': ['string']}> and i think that people usually want do differentiate between GET and POST requests, not GET and POST data. so i'm also for request.method. maybe even is_get() and is_post(). i understand that even currently you can do it with request.META['REQUEST_METHOD'], but it's too long and ugly. and because of that it does not look like the recommended approach. gabor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users -~----------~----~----~----~------~----~------~--~---