Commits

Jakub Wilk committed 2a15f48 Merge

Merge.

  • Participants
  • Parent commits 3faf442, 6ef313b

Comments (0)

Files changed (6)

File marasca/app/views.py

     response = django.http.HttpResponse(template.render(context))
     return response
 
+def temporary_overload(request):
+    template = get_template('503.html')
+    context = Context(request)
+    response = django.http.HttpResponse(template.render(context), status=503)
+    response['Retry-After'] = 60
+    return response
+
 @django.views.decorators.cache.never_cache
 def process_query(request, corpus_id, query=False, page_start=0, nth=None):
     settings = get_settings(request)
                 # With random sample on, rerunning query makes sense
                 # even if query text didn't change
                 settings.need_query_remake(True)
-            qinfo = run_query(connection, settings, corpus, query, l, r)
+            try:
+                qinfo = run_query(connection, settings, corpus, query, l, r)
+            except poliqarp.Busy:
+                return temporary_overload(request)
             if not isinstance(qinfo, Exception) and nth is not None:
                 qinfo.rinfo = extract_result_info(connection, settings, corpus, nth)
         if isinstance(qinfo, (poliqarp.Busy, poliqarp.QueryRunning)):

File marasca/locale/en/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: Marasca (Poliqarp web interface)\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-05-14 03:15+0200\n"
+"POT-Creation-Date: 2012-06-08 21:59+0200\n"
 "PO-Revision-Date: 2009-11-05 21:31+0100\n"
 "Last-Translator: Jakub Wilk <jwilk@jwilk.net>\n"
 "Language-Team: none\n"
 msgid "There's been an error. It's been reported to the site administrators and should be fixed shortly. Thanks for your patience."
 msgstr ""
 
+msgid "Service unavailable (503)"
+msgstr ""
+
+msgid "Service unavailable"
+msgstr ""
+
+msgid "The server is currently unable to handle the request due to a temporary overload."
+msgstr ""
+
 msgid ""
 "\n"
 "The search engine, made available by\n"

File marasca/locale/pl/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: Marasca (Poliqarp web interface)\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-05-14 03:15+0200\n"
-"PO-Revision-Date: 2012-03-05 15:37+0100\n"
-"Last-Translator: Janusz S. Bień <jsbien@uw.edu.pl>\n"
+"POT-Creation-Date: 2012-06-08 21:59+0200\n"
+"PO-Revision-Date: 2009-11-05 21:31+0100\n"
+"Last-Translator: Jakub Wilk <jwilk@jwilk.net>\n"
 "Language-Team: none\n"
 "Language: pl\n"
 "MIME-Version: 1.0\n"
 msgid "There's been an error. It's been reported to the site administrators and should be fixed shortly. Thanks for your patience."
 msgstr "Wystąpił niespodziewany błąd. Został on zgłoszony administratorowi strony i powinien zostać wkrótce naprawiony. Dziękujemy za cierpliwość."
 
+msgid "Service unavailable (503)"
+msgstr "Usługa niedostępna (503)"
+
+msgid "Service unavailable"
+msgstr "Usługa niedostępna"
+
+msgid "The server is currently unable to handle the request due to a temporary overload."
+msgstr "Serwer nie może obecnie obsłużyć zapytania z powodu chwilowego przeciążenia."
+
 msgid ""
 "\n"
 "The search engine, made available by\n"

File marasca/settings/__init__.py

File contents unchanged.

File marasca/templates/500.html

File contents unchanged.

File marasca/templates/503.html

+{% extends "error.html" %}
+{% load i18n %}
+
+{% block title %}
+{% trans "Service unavailable (503)" %}
+{% endblock %}
+
+{% block summary %}
+{% trans "Service unavailable" %} <span>(503)</span>
+{% endblock %}
+
+{% block info %}
+{% trans "The server is currently unable to handle the request due to a temporary overload." %}
+{% endblock %}
+
+{# vim:set ts=4 sw=4 et: #}