Django

Code

Ticket #4404 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

LatestCommentsFeed causing AssertionError due to slicing

Reported by: Stuart Williams <stuart@sidereal.ca> Assigned to: adrian
Milestone: Component: django.contrib.comments
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by mtredinnick)

LatestCommentsFeed from contrib/comments/feeds.py calls upon LatestFreeCommentsFeed, which slices the result. This causes an AssertionError:

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/
views.py" in feed
  19. feedgen = f(slug, request.path).get_feed(param)
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/
feeds.py" in get_feed
  94. for item in self.__get_dynamic_attr('items', obj):
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/
feeds.py" in __get_dynamic_attr
  51. return attr()
File "/usr/lib/python2.5/site-packages/django/contrib/comments/
feeds.py" in items
  36. qs = qs.filter(is_removed=False)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
filter
  368. return self._filter_or_exclude(None, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
_filter_or_exclude
  381. "Cannot filter a query once a slice has been taken."

  AssertionError at /rss/comments/
  Cannot filter a query once a slice has been taken. 

Sorry about the lack of further details, but I'm pretty new to both Python and Django... Thanks!

Attachments

4404.patch (1.1 kB) - added by SmileyChris on 05/28/07 01:07:52.

Change History

05/28/07 01:03:56 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

Thanks for the report, Stuart. Glad we got to the bottom of this (this ticket follows an IRC troubleshooting session)

05/28/07 01:07:17 changed by SmileyChris

To explain the problem, LatestCommentsFeed.items is getting a sliced queryset (from LatestFreeCommentsFeed.items) and then trying to filter on it. Which you can't do.

Here comes the patch...

05/28/07 01:07:52 changed by SmileyChris

  • attachment 4404.patch added.

05/28/07 01:26:30 changed by SmileyChris

  • has_patch set to 1.
  • stage changed from Accepted to Ready for checkin.

06/01/07 06:54:18 changed by mtredinnick

  • description changed.

06/01/07 06:58:18 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5408]) Fixed #4404 -- Fixed LatestCommentsFeed? query problem. Thanks, SmileyChris?.


Add/Change #4404 (LatestCommentsFeed causing AssertionError due to slicing)




Change Properties
Action