Google Groups Home
Help | Sign in
QueryDict.iteritems behaves differently than QueryDict.items
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jure Vrscaj  
View profile
(1 user)  More options Jul 3, 6:45 pm
From: Jure Vrscaj <jure.vrs...@gmail.com>
Date: Thu, 3 Jul 2008 15:45:02 -0700 (PDT)
Local: Thurs, Jul 3 2008 6:45 pm
Subject: QueryDict.iteritems behaves differently than QueryDict.items
I found the ticket for this strange behaviour of QueryDict, which
meant I wasn't alone having a problem with it - http://code.djangoproject.com/ticket/7331,
and submited a patch.

It's actually MultiValueDict that is the cause, but let's clarify
things a little, first.

Consider this scenario:

>>> from django.http import QueryDict
>>> qd = QueryDict("a=1&b=2")
>>> qd.items()

[(u'a', u'1'), (u'b', u'2')]

>>> d = {}
>>> d.update(qd)
>>> d.items()

[(u'a', [u'1']), (u'b', [u'2'])]

Updating a dict with QueryDict as input results in having dict's
values converted to lists, which is broken IMO. The issue is with
MultiValueDict.iteritems() behaving differently than
MultiValueDict.items(). One yields lists, while the other returns
normal values.

Could this be fixed in 1.0? It breaks compatibility, I know.

regards,
jure


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ludvig Ericson  
View profile
 More options Jul 3, 7:54 pm
From: Ludvig Ericson <ludvig.eric...@gmail.com>
Date: Fri, 4 Jul 2008 01:54:07 +0200
Local: Thurs, Jul 3 2008 7:54 pm
Subject: Re: QueryDict.iteritems behaves differently than QueryDict.items
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jul 4, 2008, at 00:45, Jure Vrscaj wrote:

> Could this be fixed in 1.0? It breaks compatibility, I know.

Although I'm not in any kind of position of making such a decision, I  
can make an educated guess: no. The reason is that most developers  
currently focus on getting a Django 1.0 out the door, and so there'll  
be little to no time for a core committer to actually look at the  
patch and commit it, adding tests and that.

That said, you should *definitely* file a bug report, and attach a  
patch that fixes the misbehavior and also add a regression test. Doubt  
there'll be any docs needed for this.

Also, what compatibility does it break? I can't see how this is a  
common use-case.

Regards,
Ludvig "toxik" Ericson
ludvig.eric...@gmail.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkhtZp8ACgkQXnZ94Kd6KaettQCfbC6DfVjwbKj+1kcK4lXbnHs0
ar4AniFUpLSjQpe7PBjFnkluGqkSoJVS
=o0QH
-----END PGP SIGNATURE-----


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malcolm Tredinnick  
View profile
 More options Jul 4, 1:40 am
From: Malcolm Tredinnick <malc...@pointy-stick.com>
Date: Fri, 04 Jul 2008 15:40:27 +1000
Local: Fri, Jul 4 2008 1:40 am
Subject: Re: QueryDict.iteritems behaves differently than QueryDict.items

On Fri, 2008-07-04 at 01:54 +0200, Ludvig Ericson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1

> On Jul 4, 2008, at 00:45, Jure Vrscaj wrote:

> > Could this be fixed in 1.0? It breaks compatibility, I know.

> Although I'm not in any kind of position of making such a decision, I  
> can make an educated guess: no. The reason is that most developers  
> currently focus on getting a Django 1.0 out the door, and so there'll  
> be little to no time for a core committer to actually look at the  
> patch and commit it, adding tests and that.

We're always going to look at things like this. It's 10 minutes of
effort. :-)

Certainly file a ticket so that the information doesn't get lost, Jure.
The inconsistency looks a little wrong, although I'd have to think a bit
about which return type is the "right" one, since there are arguments
both ways.

Malcolm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jure Vrscaj  
View profile
 More options Jul 4, 5:13 am
From: Jure Vrscaj <jure.vrs...@gmail.com>
Date: Fri, 4 Jul 2008 02:13:42 -0700 (PDT)
Local: Fri, Jul 4 2008 5:13 am
Subject: Re: QueryDict.iteritems behaves differently than QueryDict.items

> Also, what compatibility does it break? I can't see how this is a  common use-case.

It might break existing code, code that depends on iteritems()
yielding lists. Maybe not a common use case, but it got me scratching
my head more than once.

On Jul 4, 7:40 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

> Certainly file a ticket so that the information doesn't get lost, Jure.
> The inconsistency looks a little wrong, although I'd have to think a bit
> about which return type is the "right" one, since there are arguments
> both ways.

The ticket, patch and test is here: http://code.djangoproject.com/ticket/7331

Milestone is currently set to post-1.0, but I'd argue it's better to
fix it for 1.0, if at all.

Thanks for looking into it.

regards,
jure


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tai Lee  
View profile
 More options Jul 4, 10:22 pm
From: Tai Lee <real.hu...@mrmachine.net>
Date: Fri, 4 Jul 2008 19:22:26 -0700 (PDT)
Local: Fri, Jul 4 2008 10:22 pm
Subject: Re: QueryDict.iteritems behaves differently than QueryDict.items
1.0 should ideally ship with Zarro Boogs, so any bugs (not DDN)
especially trivial ones with a patch including relavent tests / docs
should be marked for 1.0 milestone, I think ;)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google