summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-06-07 21:19:50 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-06-07 21:19:50 -0400
commite215c1d15b049b04f7a2497c07d3c9a3f380638d (patch)
tree65257c6d9b55810f39a641edc1bb6dec2d474393
parent57033196f904477631c397fab50681f0d1aa7834 (diff)
downloadaskbot-e215c1d15b049b04f7a2497c07d3c9a3f380638d.tar.gz
askbot-e215c1d15b049b04f7a2497c07d3c9a3f380638d.tar.bz2
askbot-e215c1d15b049b04f7a2497c07d3c9a3f380638d.zip
envelope turns on correctly for responses, but not for mentions yet, added urls for cache monitoring
-rw-r--r--forum/doc/INSTALL3
-rw-r--r--forum/models/answer.py8
-rw-r--r--forum/models/base.py11
-rw-r--r--forum/models/content.py9
-rw-r--r--forum/models/meta.py10
-rw-r--r--forum/models/question.py9
-rw-r--r--forum/tests.py6
-rw-r--r--keyedcache/templates/keyedcache/delete.html3
-rw-r--r--keyedcache/templates/keyedcache/stats.html3
-rw-r--r--keyedcache/templates/keyedcache/view.html3
-rwxr-xr-xsettings_local.py.dist6
-rw-r--r--urls.py1
12 files changed, 32 insertions, 40 deletions
diff --git a/forum/doc/INSTALL b/forum/doc/INSTALL
index f1d1e498..55b8614d 100644
--- a/forum/doc/INSTALL
+++ b/forum/doc/INSTALL
@@ -52,11 +52,12 @@ http://github.com/dcramer/django-sphinx/tree/master/djangosphinx
8. sphinx search engine (optional, works together with djangosphinx)
http://sphinxsearch.com/downloads.html
-9. recaptcha_django
+9. recaptcha_django (installed through svn)
http://code.google.com/p/recaptcha-django/
10. python recaptcha module
http://code.google.com/p/recaptcha/
+easy_install recaptcha-client
Notice that you will need to register with recaptcha.net and receive
recaptcha public and private keys that need to be saved in your
settings_local.py file
diff --git a/forum/models/answer.py b/forum/models/answer.py
index b4e8963e..e8ff2e50 100644
--- a/forum/models/answer.py
+++ b/forum/models/answer.py
@@ -5,7 +5,7 @@ from django.template.defaultfilters import slugify
from django.core.urlresolvers import reverse
from forum.models.base import AnonymousContent, DeletableContent
from forum.models.base import ContentRevision
-from forum.models.base import save_post, parse_post_text
+from forum.models.base import parse_post_text, parse_and_save_post
from forum.models import content
from forum.models.question import Question
from forum import const
@@ -26,7 +26,7 @@ class AnswerManager(models.Manager):
answer.last_edited_at = added_at
answer.wikified_at = added_at
- answer.save()
+ answer.parse_and_save()
answer.add_revision(
revised_by = author,
@@ -91,8 +91,8 @@ class Answer(content.Content, DeletableContent):
class Meta(content.Content.Meta):
db_table = u'answer'
- save = save_post
parse = parse_post_text
+ parse_and_save = parse_and_save_post
def get_updated_activity_data(self, created = False):
#todo: simplify this to always return latest revision for the second
@@ -117,7 +117,7 @@ class Answer(content.Content, DeletableContent):
#self.html is denormalized in save()
self.text = text
#todo: bug wiki has no effect here
- self.save()
+ self.parse_and_save()
self.add_revision(
revised_by=edited_by,
diff --git a/forum/models/base.py b/forum/models/base.py
index d832b71c..29d4fff3 100644
--- a/forum/models/base.py
+++ b/forum/models/base.py
@@ -4,7 +4,6 @@ from django.utils.html import strip_tags
from django.contrib.auth.models import User
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
-from django.contrib.sitemaps import ping_google
#todo: maybe merge forum.utils.markup and forum.utils.html
from forum.utils import markup
from forum.utils.html import sanitize_html
@@ -98,8 +97,9 @@ def parse_post_text(post):
}
return data
-def save_post(post, **kwargs):
- """generic save method to use with posts
+def parse_and_save_post(post, **kwargs):
+ """generic method to use with posts to be used prior to saving
+ post edit or addition
"""
data = post.parse()
@@ -123,6 +123,9 @@ def save_post(post, **kwargs):
super(post.__class__, post).save(**kwargs)
last_author = post.get_last_author()
+
+ last_author = post.get_last_author()
+
#create new mentions
for u in newly_mentioned_users:
from forum.models.user import Activity
@@ -148,7 +151,7 @@ def save_post(post, **kwargs):
try:
ping_google()
except Exception:
- logging.debug('problem pinging google did you register the sitemap with google?')
+ logging.debug('cannot ping google - did you register with them?')
class UserContent(models.Model):
user = models.ForeignKey(User, related_name='%(class)ss')
diff --git a/forum/models/content.py b/forum/models/content.py
index eb2b423e..ec7f26b8 100644
--- a/forum/models/content.py
+++ b/forum/models/content.py
@@ -44,13 +44,6 @@ class Content(models.Model):
abstract = True
app_label = 'forum'
- def save(self,**kwargs):
- super(Content,self).save(**kwargs)
- try:
- ping_google()
- except Exception:
- logging.debug('problem pinging google did you register you sitemap with google?')
-
def get_comments(self):
comments = self.comments.all().order_by('id')
return comments
@@ -72,7 +65,7 @@ class Content(models.Model):
user=user,
added_at=added_at
)
- comment.save()
+ comment.parse_and_save()
self.comment_count = self.comment_count + 1
self.save()
return comment
diff --git a/forum/models/meta.py b/forum/models/meta.py
index ee0d92ae..59becc24 100644
--- a/forum/models/meta.py
+++ b/forum/models/meta.py
@@ -89,6 +89,10 @@ class Comment(base.MetaContent, base.UserContent):
ordering = ('-added_at',)
db_table = u'comment'
+ #these two are methods
+ parse = base.parse_post_text
+ parse_and_save = base.parse_and_save_post
+
def get_origin_post(self):
return self.content_object.get_origin_post()
@@ -99,12 +103,6 @@ class Comment(base.MetaContent, base.UserContent):
def set_text(self, text):
self.comment = text
- def parse(self):
- return base.parse_post_text(self)
-
- def save(self,**kwargs):
- base.save_post(self)
-
def get_updated_activity_data(self, created = False):
if self.content_object.__class__.__name__ == 'Question':
return const.TYPE_ACTIVITY_COMMENT_QUESTION, self
diff --git a/forum/models/question.py b/forum/models/question.py
index c6c16578..8e137e2e 100644
--- a/forum/models/question.py
+++ b/forum/models/question.py
@@ -12,7 +12,7 @@ from django.utils.translation import ugettext as _
from forum.models.tag import Tag, MarkedTag
from forum.models import signals
from forum.models.base import AnonymousContent, DeletableContent, ContentRevision
-from forum.models.base import save_post, parse_post_text
+from forum.models.base import parse_post_text, parse_and_save_post
from forum.models import content
from forum import const
from forum.utils.lists import LazyList
@@ -54,7 +54,7 @@ class QuestionManager(models.Manager):
question.last_edited_at = added_at
question.wikified_at = added_at
- question.save()
+ question.parse_and_save()
question.add_revision(
author=author,
@@ -319,6 +319,7 @@ class Question(content.Content, DeletableContent):
db_table = u'question'
parse = parse_post_text
+ parse_and_save = parse_and_save_post
def delete(self):
super(Question, self).delete()
@@ -421,7 +422,7 @@ class Question(content.Content, DeletableContent):
if self.wiki == False and wiki == True:
self.wiki = True
- self.save()
+ self.parse_and_save()
# Update the Question tag associations
if latest_revision.tagnames != tags:
@@ -466,7 +467,7 @@ class Question(content.Content, DeletableContent):
"""
initial_addition = (self.pk is None)
- save_post(self, **kwargs)
+ super(Question, self).save(**kwargs)
if initial_addition:
tags = Tag.objects.get_or_create_multiple(
diff --git a/forum/tests.py b/forum/tests.py
index c2e1765f..d93e7d4e 100644
--- a/forum/tests.py
+++ b/forum/tests.py
@@ -204,12 +204,12 @@ class UpdateNotificationTests(TestCase):
)
def test_comments_to_post_authors(self):
- self.reset_response_counts()
self.question.apply_edit(
edited_by = self.u14,
text = 'now much better',
comment = 'improved text'
)
+ self.reset_response_counts()
time.sleep(1)
timestamp = datetime.datetime.now()
self.question.add_comment(
@@ -250,7 +250,7 @@ class UpdateNotificationTests(TestCase):
text = 'now much better',
comment = 'improved text'
)
- self.reset_repsonse_counters()
+ self.reset_response_counts()
time.sleep(1)
timestamp = datetime.datetime.now()
self.answer1.add_comment(
@@ -360,7 +360,7 @@ class UpdateNotificationTests(TestCase):
],
[
1, 1, 1, 1,
- 0, 0, 0, 0,
+ 1, 0, 0, 0,
0, 0, 0, 0,
]
)
diff --git a/keyedcache/templates/keyedcache/delete.html b/keyedcache/templates/keyedcache/delete.html
index 9449a6d3..a6e00707 100644
--- a/keyedcache/templates/keyedcache/delete.html
+++ b/keyedcache/templates/keyedcache/delete.html
@@ -1,5 +1,5 @@
{% extends "admin/base_site.html" %}
-{% load messaging_tags i18n %}
+{% load i18n %}
{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
@@ -10,7 +10,6 @@
{% endif %}{% endblock %}
{% block content %}
-{% show_messages %}
<p>[<a href="{% url keyedcache_stats %}">Cache Stats</a>] [<a href="{% url keyedcache_view %}">View Cache</a>]</p>
<h1>Delete From Cache</h1>
<form method="POST" action="{% url keyedcache_delete %}">
diff --git a/keyedcache/templates/keyedcache/stats.html b/keyedcache/templates/keyedcache/stats.html
index 0a3f17d6..2ea3d12f 100644
--- a/keyedcache/templates/keyedcache/stats.html
+++ b/keyedcache/templates/keyedcache/stats.html
@@ -1,5 +1,5 @@
{% extends "admin/base_site.html" %}
-{% load messaging_tags i18n %}
+{% load i18n %}
{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
@@ -9,7 +9,6 @@
{% endif %}{% endblock %}
{% block content %}
-{% show_messages %}
<p>[<a href="{% url keyedcache_view %}">View Cache</a>] [<a href="{% url keyedcache_delete %}">Delete from Cache</a>]
<h1>Cache Stats</h1>
<p>Backend: {{ cache_backend }} ({% if cache_running %}running{% else %}down{% endif %})</p>
diff --git a/keyedcache/templates/keyedcache/view.html b/keyedcache/templates/keyedcache/view.html
index e28c5a0e..3034a98f 100644
--- a/keyedcache/templates/keyedcache/view.html
+++ b/keyedcache/templates/keyedcache/view.html
@@ -1,5 +1,5 @@
{% extends "admin/base_site.html" %}
-{% load messaging_tags i18n %}
+{% load i18n %}
{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
@@ -10,7 +10,6 @@
{% endif %}{% endblock %}
{% block content %}
-{% show_messages %}
<p>[<a href="{% url keyedcache_stats %}">Cache Stats</a>] [<a href="{% url keyedcache_delete %}">Delete from Cache</a>]
<h1>Cache Keys</h1>
<p style="font-size:82%;">{% for key in cached_keys %}{{ key }}, {% endfor %}
diff --git a/settings_local.py.dist b/settings_local.py.dist
index fc6815da..d6f537fb 100755
--- a/settings_local.py.dist
+++ b/settings_local.py.dist
@@ -29,11 +29,9 @@ DATABASE_ENGINE = '' #mysql, etc
DATABASE_HOST = ''
DATABASE_PORT = ''
-#set this value to 'dummy://' if you don't want to use cache, or set up your favourite caching mechanism
+#setup memcached for production use!
#see http://docs.djangoproject.com/en/1.1/topics/cache/ for details
-#example (set local file system cache in a cache folder in the root of the askbot install):
-#CACHE_BACKEND = 'file://%s' % os.path.join(os.path.dirname(__file__),'cache').replace('\\','/')
-CACHE_BACKEND = 'dummy://'
+CACHE_BACKEND = 'locmem://'
#If you use memcache you may want to uncomment the following line to enable memcached based sessions
#SESSION_ENGINE = 'django.contrib.sessions.backends.cache_db'
diff --git a/urls.py b/urls.py
index 2a136cfb..062e24b6 100644
--- a/urls.py
+++ b/urls.py
@@ -10,6 +10,7 @@ admin.autodiscover()
urlpatterns = patterns('',
(r'^%s' % settings.FORUM_SCRIPT_ALIAS, include('forum.urls')),
(r'^admin/', include(admin.site.urls)),
+ (r'^cache/', include('keyedcache.urls')),
(r'^settings/', include('livesettings.urls')),
)