Josh VanderLinden committed 6f3a99d

Worked on feed caching.

Comments (0)

Files changed (1)


 from django.contrib.syndication.feeds import Feed
+from django.core.cache import cache
 from django.core.urlresolvers import reverse
 from django.contrib.sites.models import Site
-from articles.models import Article
+from articles.models import Article, Tag
 SITE = Site.objects.get_current()
         return reverse('articles_archive')
     def items(self):
-        return'-publish_date')[:5]
+        key = 'latest_articles'
+        articles = cache.get(key)
+        if articles is None:
+            articles ='-publish_date')[:15]
+            cache.set(key, articles)
+        return articles
     def item_author_name(self, item):
     def get_object(self, bits):
         if len(bits) != 1:
             raise FeedDoesNotExist
-        return[0])
+        return Tag.objects.get(name__exact=bits[0])
     def title(self, obj):
-        return "%s: Newest Articles Tagged '%s'" % (, obj.slug)
+        return "%s: Newest Articles Tagged '%s'" % (,
     def link(self, obj):
         if not obj:
         return obj.get_absolute_url()
     def description(self, obj):
-        return "Articles Tagged '%s'" % obj.slug
+        return "Articles Tagged '%s'" %
     def items(self, obj):
         return self.item_set(obj)[:10]
     def item_set(self, obj):
-        return'-publish_date')
+        key = 'articles_for_%s' %
+        #articles = cache.get(key)
+        #if articles is None:
+        articles ='-publish_date')
+        #cache.set(key, articles)
+        return articles
     def item_author_name(self, item):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.