Permalink
Browse files

[bug 693988] Stop caching previews.

  • Loading branch information...
1 parent 92cee09 commit 7048ee1d6a76fb5b56c23ebc6292b35c221cf37e @rlr rlr committed Oct 12, 2011
Showing with 15 additions and 12 deletions.
  1. +15 −12 apps/questions/models.py
View
@@ -67,12 +67,7 @@ def __unicode__(self):
@property
def content_parsed(self):
- cache_key = self.html_cache_key % self.id
- html = cache.get(cache_key)
- if html is None:
- html = wiki_to_html(self.content)
- cache.add(cache_key, html)
- return html
+ return _content_parsed(self)
def clear_cached_properties(self):
cache.delete(self.html_cache_key % self.id)
@@ -278,12 +273,7 @@ def __unicode__(self):
@property
def content_parsed(self):
- cache_key = self.html_cache_key % self.id
- html = cache.get(cache_key)
- if not html:
- html = wiki_to_html(self.content)
- cache.add(cache_key, html)
- return html
+ return _content_parsed(self)
def clear_cached_properties(self):
cache.delete(self.html_cache_key % self.id)
@@ -481,3 +471,16 @@ def _has_beta(version, dev_releases):
"""
return version in [re.search('(\d+\.)+\d+', s).group(0)
for s in dev_releases.keys()]
+
+
+def _content_parsed(obj):
+ if not obj.id:
+ # Don't cache if we don't have an ID (previews)
+ return wiki_to_html(obj.content)
+
+ cache_key = obj.html_cache_key % obj.id
+ html = cache.get(cache_key)
+ if html is None:
+ html = wiki_to_html(obj.content)
+ cache.add(cache_key, html)
+ return html

0 comments on commit 7048ee1

Please sign in to comment.