Skip to content

Commit

Permalink
[bug 693988] Stop caching previews.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Oct 12, 2011
1 parent 92cee09 commit 7048ee1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions apps/questions/models.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.