Ticket #13927 (new Bug)
plone.portlet.collection producing IndexError when displaying random result
Reported by: | muttnik | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | Unknown | Version: | 4.3 |
Keywords: | Cc: |
Description
I am experiencing an error with plone.portlet.collection version 2.1.5 and 2.2.1. I have the portlet configured to display a single random item. At times (randomly!) the portlet fails to render when the page is loaded and an "IndexError" is logged. As the number of items returned by the underlying Collection becomes greater, the frequency of the error increases.
Overview of my setup:
- A new-style Collection is configured to aggregate items from the site based on a Type criterion. Result Limit setting 1000.
- A plone.portlet.collection portlet is added to the site and configured to select a single random item from the Collection results.
I am not entirely certain, but have a hunch that batching of the Collection results may be a factor in producing the error. I have never seen the error occur when the Collection is returning a total of 10 or less items. At 80+ results, the portlet seems to fail more often than it successfully renders, at 200+ results the portlet almost never displays.
2014-03-11T11:14:20 ERROR portlets Error while determining renderer availability of portlet ('context' '/phyc/welcome' u'fleet-pic-test'): list index out of range Traceback (most recent call last): File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.portlets-2.2-py2.7.egg/plone/portlets/manager.py", line 117, in _lazyLoadPortlets isAvailable = renderer.available File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.portlet.collection-2.2.1-py2.7.egg/plone/portlet/collection/collection.py", line 114, in available return len(self.results()) File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.memoize-1.1.1-py2.7.egg/plone/memoize/instance.py", line 51, in memogetter val=func(*args, **kwargs) File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.portlet.collection-2.2.1-py2.7.egg/plone/portlet/collection/collection.py", line 131, in results return self._random_results() File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.portlet.collection-2.2.1-py2.7.egg/plone/portlet/collection/collection.py", line 162, in _random_results results = random.sample(results, limit) File "/usr/lib/python2.7/random.py", line 344, in sample result[i] = population[j] File "/home/phyc/test4.3.2/buildout-cache/eggs/plone.batching-1.0-py2.7.egg/plone/batching/batch.py", line 129, in __getitem__ return self._sequence[index] File "/home/phyc/test4.3.2/buildout-cache/eggs/Products.ZCatalog-2.13.23-py2.7.egg/Products/ZCatalog/Lazy.py", line 191, in __getitem__ value = data[index] = self._func(self._seq[index]) File "/home/phyc/test4.3.2/buildout-cache/eggs/Products.ZCatalog-2.13.23-py2.7.egg/Products/ZCatalog/Lazy.py", line 308, in __getitem__ return self._seq[index][1] IndexError: list index out of range
Quick Update...
I explicitly turned off batching in ...plone/portlet/collection/collection.py as shown below and the problem has vanished. Not sure how this will impact performance of the portlet on very large result samples.