From d8409c26a0bf40b336e036aecf3224aa74f5b8f3 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 16 Mar 2012 20:59:44 +0100 Subject: [PATCH] Fix for mongo. pymongo does not rewind a cursor after leaving a for loop. So let us do it by hand. Well. --- mediagoblin/listings/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mediagoblin/listings/views.py b/mediagoblin/listings/views.py index d96b9606..5c365ed2 100644 --- a/mediagoblin/listings/views.py +++ b/mediagoblin/listings/views.py @@ -29,13 +29,16 @@ def _get_tag_name_from_entries(media_entries, tag_slug): """ # ... this is slightly hacky looking :\ tag_name = tag_slug - # if media_entries.count(): + for entry in media_entries: for tag in entry.tags: if tag['slug'] == tag_slug: tag_name = tag['name'] break break + # TODO: Remove after SQL-switch, it's mongo specific + if hasattr(media_entries, "rewind"): + media_entries.rewind() return tag_name -- 2.25.1