Fix for mongo.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 16 Mar 2012 19:59:44 +0000 (20:59 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 16 Mar 2012 20:20:14 +0000 (21:20 +0100)
pymongo does not rewind a cursor after leaving a for loop.
So let us do it by hand. Well.

mediagoblin/listings/views.py

index d96b9606040d340899222403c0a2fc6b8e52b7b7..5c365ed2fc03b812ac7dfd87022c69208e2a14e9 100644 (file)
@@ -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