summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-04-17 15:27:31 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-04-17 15:27:31 -0500
commitd6ee95a99cc174db4cba09f407caabb0fb67c853 (patch)
treeaeed18a5a6cb93404f39e5aad99aa6b0af266f20
parentca5efbe3667058e2bfd36403c1236819f954ee40 (diff)
downloadaskbot-d6ee95a99cc174db4cba09f407caabb0fb67c853.tar.gz
askbot-d6ee95a99cc174db4cba09f407caabb0fb67c853.tar.bz2
askbot-d6ee95a99cc174db4cba09f407caabb0fb67c853.zip
hopefully fixed the caching issue of the question summary when an answer to a question was deleted.
-rw-r--r--askbot/models/__init__.py6
-rw-r--r--askbot/models/question.py20
2 files changed, 11 insertions, 15 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 09ec0018..165808d9 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -1178,6 +1178,7 @@ def user_delete_answer(
answer.save()
answer.thread.update_answer_count()
+ answer.thread.invalidate_cached_data()
logging.debug('updated answer count to %d' % answer.thread.answer_count)
signals.delete_question_or_answer.send(
@@ -1247,6 +1248,7 @@ def user_reopen_question(
self.assert_can_reopen_question(question)
question.thread.set_closed_status(closed=False, closed_by=self, closed_at=timestamp, close_reason=None)
+@auto_now_timestamp
def user_delete_post(
self,
post = None,
@@ -2005,14 +2007,14 @@ def _process_vote(user, post, timestamp=None, cancel=False, vote_type=None):
else:
auth.onDownVoted(vote, post, user, timestamp)
+ post.thread.invalidate_cached_data()
+
if post.post_type == 'question':
#denormalize the question post score on the thread
post.thread.score = post.score
post.thread.save()
post.thread.update_summary_html()
- post.thread.invalidate_cached_data()
-
if cancel:
return None
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 8c61385c..79775afc 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -438,17 +438,7 @@ class Thread(models.Model):
)
def invalidate_cached_thread_content_fragment(self):
- """we do not precache the fragment here, as re-generating
- the the fragment takes a lot of data, so we just
- invalidate the cached item
-
- Note: the cache key generation code is copy-pasted
- from coffin/template/defaulttags.py no way around
- that unfortunately
- """
- args_md5 = md5_constructor(str(self.id))
- key = 'template.cache.%s.%s' % ('thread-content-html', args_md5.hexdigest())
- cache.cache.delete(key)
+ cache.cache.delete(self.SUMMARY_CACHE_KEY_TPL % self.id)
def get_post_data_cache_key(self, sort_method = None):
return 'thread-data-%s-%s' % (self.id, sort_method)
@@ -463,7 +453,8 @@ class Thread(models.Model):
def invalidate_cached_data(self):
self.invalidate_cached_post_data()
- self.invalidate_cached_thread_content_fragment()
+ #self.invalidate_cached_thread_content_fragment()
+ self.update_summary_html()
def get_cached_post_data(self, sort_method = None):
"""returns cached post data, as calculated by
@@ -770,7 +761,10 @@ class Thread(models.Model):
# use `<<<` and `>>>` because they cannot be confused with user input
# - if user accidentialy types <<<tag-name>>> into question title or body,
# then in html it'll become escaped like this: &lt;&lt;&lt;tag-name&gt;&gt;&gt;
- regex = re.compile(r'<<<(%s)>>>' % const.TAG_REGEX_BARE)
+ regex = re.compile(
+ r'<<<(%s)>>>' % const.TAG_REGEX_BARE,
+ re.UNICODE
+ )
while True:
match = regex.search(html)