[extensions-web] views: Update the indexes explicitly
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] views: Update the indexes explicitly
- Date: Mon, 22 Jul 2013 04:06:48 +0000 (UTC)
commit 3f411ce4ac2a966474e49b14b486f40368190658
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jul 18 13:57:02 2013 -0400
views: Update the indexes explicitly
Doing this post-save means we'll contest for the Xapian write
lock when we unrelated writes to indexing. It's still possible
for two inline edits or reviews to happen simultaneously, but
the chance is probably not enough to be concerned about.
sweettooth/extensions/models.py | 1 +
sweettooth/extensions/search.py | 9 +++++++--
sweettooth/extensions/views.py | 2 ++
3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index d31402a..b7352ff 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -393,3 +393,4 @@ class ExtensionVersion(models.Model):
submitted_for_review = Signal(providing_args=["request", "version"])
reviewed = Signal(providing_args=["request", "version", "review"])
+extension_updated = Signal()
diff --git a/sweettooth/extensions/search.py b/sweettooth/extensions/search.py
index 040aa7a..e57a993 100644
--- a/sweettooth/extensions/search.py
+++ b/sweettooth/extensions/search.py
@@ -5,6 +5,7 @@ from django.conf import settings
from django.db.models import signals
from extensions.models import Extension, ExtensionVersion
+from extensions.models import reviewed, extension_updated
def index_extension(extension):
if extension.latest_version is None:
@@ -37,9 +38,13 @@ def delete_extension(extension):
db.delete_document(idterm)
-def post_extension_save_handler(instance, **kwargs):
+def reviewed_handler(sender, request, version, review, **kwargs):
+ index_extension(version.extension)
+reviewed.connect(reviewed_handler)
+
+def extension_updated_handler(instance, **kwargs):
index_extension(instance)
-signals.post_save.connect(post_extension_save_handler, sender=Extension)
+reviewed.connect(extension_updated_handler)
def post_extension_delete_handler(instance, **kwargs):
delete_extension(instance)
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index f0adb62..56e10da 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -289,6 +289,8 @@ def ajax_inline_edit_view(request, extension):
else:
return HttpResponseForbidden()
+ models.extension_updated.send(sender=extension)
+
extension.save()
return value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]