changeset 470:d9b6c4ec1977

For #227; rework last commit slightly (r508). Adapt the desired forums signal signature to the queued_search API instead of the other way around.
author Brian Neal <bgneal@gmail.com>
date Wed, 17 Aug 2011 01:29:27 +0000
parents 3b30286adba5
children d83296cac940
files gpp/forums/search_indexes.py gpp/forums/signals.py
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/forums/search_indexes.py	Wed Aug 17 01:02:08 2011 +0000
+++ b/gpp/forums/search_indexes.py	Wed Aug 17 01:29:27 2011 +0000
@@ -24,6 +24,9 @@
     def _teardown_save(self, model):
         topic_content_update.disconnect(self.enqueue_save)
 
+    def enqueue_save(self, sender, **kwargs):
+        return self.enqueue('update', sender)
+
     def can_index(self, instance):
         return instance.forum.id in Forum.objects.public_forum_ids()
 
@@ -46,6 +49,9 @@
     def _teardown_save(self, model):
         post_content_update.disconnect(self.enqueue_save)
 
+    def enqueue_save(self, sender, **kwargs):
+        return self.enqueue('update', sender)
+
     def can_index(self, instance):
         return instance.topic.forum.id in Forum.objects.public_forum_ids()
 
--- a/gpp/forums/signals.py	Wed Aug 17 01:02:08 2011 +0000
+++ b/gpp/forums/signals.py	Wed Aug 17 01:29:27 2011 +0000
@@ -74,18 +74,16 @@
 # This signal is sent when a topic has had its textual content (title) changed.
 # The provided arguments are: 
 #   sender - the topic model instance 
-#   instance - the topic model instance
 #   created - True if the topic is new, False if updated
 
-topic_content_update = django.dispatch.Signal(providing_args=['action'])
+topic_content_update = django.dispatch.Signal(providing_args=['created'])
 
 # This signal is sent when a post has had its textual content (body) changed.
 # The provided arguments are: 
 #   sender - the post model instance 
-#   instance - the topic model instance
 #   created - True if the post is new, False if updated
 
-post_content_update = django.dispatch.Signal(providing_args=['action'])
+post_content_update = django.dispatch.Signal(providing_args=['created'])
 
 
 def notify_new_topic(topic):
@@ -93,7 +91,7 @@
     Sends the topic_content_update signal for a new topic instance.
 
     """
-    topic_content_update.send_robust(topic, instance=topic, created=True)
+    topic_content_update.send_robust(topic, created=True)
 
 
 def notify_updated_topic(topic):
@@ -101,7 +99,7 @@
     Sends the topic_content_update signal for an updated topic instance.
 
     """
-    topic_content_update.send_robust(topic, instance=topic, created=False)
+    topic_content_update.send_robust(topic, created=False)
 
 
 def notify_new_post(post):
@@ -109,7 +107,7 @@
     Sends the post_content_update signal for a new post instance.
 
     """
-    post_content_update.send_robust(post, instance=post, created=True)
+    post_content_update.send_robust(post, created=True)
 
 
 def notify_updated_post(post):
@@ -117,4 +115,4 @@
     Sends the post_content_update signal for an updated post instance.
 
     """
-    post_content_update.send_robust(post, instance=post, created=False)
+    post_content_update.send_robust(post, created=False)