recent MultiValueDict.iteritems change (changeset 8399)

16 views
Skip to first unread message

James Turk

unread,
Aug 20, 2008, 1:09:02 AM8/20/08
to Django developers
I've been trying to stay up to date when testing locally and just
noticed 8399 seems to be the source of a break in my code where
MultiValueDict's iteritems was used. I see that this relates to
http://code.djangoproject.com/ticket/7331 and I understand a decision
had to be made.

iteritems used to return lists for the items but was changed to match
items, which only returns the last value for each key

It seems that changing my code to use lists will give almost the same
result, but would it be possible to get an "iterlists" method to
replace the iteritems which was changed?

This would be a trivial patch and I'd be happy to open a ticket and
submit it, but figured I'd bring it up here as I'd imagine a design
decision is needed on this.

Also because of this should 8399, trivial as it is, go up on
BackwardsIncompatibleChanges?

Malcolm Tredinnick

unread,
Aug 20, 2008, 9:08:46 AM8/20/08
to django-d...@googlegroups.com

On Tue, 2008-08-19 at 22:09 -0700, James Turk wrote:
[...]

> It seems that changing my code to use lists will give almost the same
> result, but would it be possible to get an "iterlists" method to
> replace the iteritems which was changed?

This is probably worth leaving until after 1.0 for now. It's not
completely clear what iterlists should do -- is it iteritems-as-lists or
itervalues-as-lists (the latter being possibly a more natural equivalent
of the the getlist() method)? Since you can loop over the keys and the
use getlist() to get each element, we haven't removed access to any
data, so I'd be inclined to wait a bit and then we can look at it.

File a patch anyway and maybe it will go in, but probably it will wait
and we have it ready for later.

> Also because of this should 8399, trivial as it is, go up on
> BackwardsIncompatibleChanges?

Yes, it should. Hopefully Gary (Wilson) will see this and make the
change, since it was his commit. It was no doubt just forgotten at the
time. Nothing malicious.

Regards,
Malcolm

Jeremy Dunck

unread,
Aug 20, 2008, 9:20:23 AM8/20/08
to django-d...@googlegroups.com
On Wed, Aug 20, 2008 at 8:08 AM, Malcolm Tredinnick
<mal...@pointy-stick.com> wrote:
...

>> Also because of this should 8399, trivial as it is, go up on
>> BackwardsIncompatibleChanges?
>
> Yes, it should. Hopefully Gary (Wilson) will see this and make the
> change, since it was his commit. It was no doubt just forgotten at the
> time. Nothing malicious.

I was in the neighborhood, so updated:
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#CorrectedMultiValueDict.iteritemstoreturnitemsratherthanlists

James Turk

unread,
Aug 20, 2008, 11:01:23 AM8/20/08
to Django developers
Quite understandable that this isn't a priority by any means, ticket
including patch is up here for posterity: http://code.djangoproject.com/ticket/8447

On Aug 20, 9:20 am, "Jeremy Dunck" <jdu...@gmail.com> wrote:
> On Wed, Aug 20, 2008 at 8:08 AM, Malcolm Tredinnick<malc...@pointy-stick.com> wrote:
>
> ...
>
> >> Also because of this should 8399, trivial as it is, go up on
> >> BackwardsIncompatibleChanges?
>
> > Yes, it should. Hopefully Gary (Wilson) will see this and make the
> > change, since it was his commit. It was no doubt just forgotten at the
> > time. Nothing malicious.
>
> I was in the neighborhood, so updated:http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Corre...

Jeremy Dunck

unread,
Aug 20, 2008, 11:17:47 AM8/20/08
to django-d...@googlegroups.com
On Wed, Aug 20, 2008 at 10:01 AM, James Turk <james....@gmail.com> wrote:
>
> Quite understandable that this isn't a priority by any means, ticket
> including patch is up here for posterity: http://code.djangoproject.com/ticket/8447

The patch was a bit off; it used iteritems in iterlists in tests.py.

I replaced the patch just now.

zvoase

unread,
Aug 21, 2008, 4:57:50 AM8/21/08
to Django developers
Wouldn't it make sense to add a keyword argument to both itervalues
and iteritems, which lets you get lists instead? That would seem
easier than writing new methods. Example:

>>> dictionary.iteritems(as_list=True)
...
Reply all
Reply to author
Forward
0 new messages