armstrong/armstrong — Issue #30: Adding multiple instances of the same item to a well causes an IndexError
Author: niran
Created: 2011-10-28 00:10:41+00:00
State: open
Labels: bugs, core.arm_wells

Consider a well with two `Story` nodes, both of which refer to the same `Story`. In `GenericForeignKeyQuerySet._prep()`, `ordering` will end up with a value like `{u'story.28461': 1}`, which has a length of one, while `model_data.["objects_ids"]` will be something like `[u'28461', u'28461']`, which has a length of two. This makes the loop over `node_content` raise an `IndexError`.

Traceback (most recent call last):

File "/home/virtualenvs/texastribune/src/django/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/home/webapps/texastribune/content/utils.py", line 45, in wrapped
context_info = func(request, *args, **kwargs)

File "/home/webapps/texastribune/content/utils.py", line 109, in wrapped
context_info = func(request, *args, **kwargs)

File "/home/webapps/texastribune/content/multimedia/views.py", line 32, in main
slideshows = get_well_content(MULTIMEDIA_SLIDESHOWS)[:2]

File "/home/virtualenvs/texastribune/lib/python2.6/site-packages/armstrong/core/arm_wells/querysets.py", line 9, in wrapper
args[0]._prep()

File "/home/virtualenvs/texastribune/lib/python2.6/site-packages/armstrong/core/arm_wells/querysets.py", line 127, in _prep
self.content[idx] = obj

IndexError: list assignment index out of range

Tribune folks, see http://www.texastribune.org/sentry/group/314093.