aboutsummaryrefslogtreecommitdiff
path: root/dicoweb/settings-sample.py
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-09-06 12:27:27 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-09-06 12:30:28 +0300
commit91bc7f6d99096ab3e16a6e80c9c0bba5c91c090d (patch)
treee664e783edc9d11189e8102443192a70a046d521 /dicoweb/settings-sample.py
parent54b21d7c9255191f8d57688332e6f2d72c95a7af (diff)
downloaddico-91bc7f6d99096ab3e16a6e80c9c0bba5c91c090d.tar.gz
dico-91bc7f6d99096ab3e16a6e80c9c0bba5c91c090d.tar.bz2
Graceful handling of unsupported response content types in dicoweb
* NEWS: Document changes * dicoweb/settings-sample.py (ONERROR): New setting. * dicoweb/views.py: Handle unsupported content types depending on ONERROR['UNHANDLED_CONTENT_TYPE']
Diffstat (limited to 'dicoweb/settings-sample.py')
-rw-r--r--dicoweb/settings-sample.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/dicoweb/settings-sample.py b/dicoweb/settings-sample.py
index 0c47378..5976cb7 100644
--- a/dicoweb/settings-sample.py
+++ b/dicoweb/settings-sample.py
@@ -131,3 +131,41 @@ LOGGING = {
DICT_SERVERS = ('gnu.org.ua',)
DICT_TIMEOUT = 10
+
+# Optional ONERROR dict controls what to do if certain errors occur.
+# So far, only one key is defined:
+#
+# UNSUPPORTED_CONTENT_TYPE
+# Specifies action to take if a DEFINE request returns article in
+# unsupported content type (with OPTION MIME enabled).
+# Value is a dict. The only mandatory key is 'action', indicating what
+# action to take. Rest of keys depend on its value as shown in the table
+# below:
+#
+# 'action': 'delete':
+# The offending article will be removed, as if the server has
+# never returned it. This can lead to inconsistencies where
+# headwords returned by MATCH will not be returned by DEFINE.
+# No additional keys are required.
+#
+# 'action': 'replace':
+# The offending content will be replaced with the value of the
+# 'message' key. Keys:
+# 'message': Text to use as a replacement [mandatory]
+# 'format_html': Boolean indicating whether to treat the text as HTML.
+# Optional. Defaults to False.
+#
+# 'action': 'display':
+# Display the result anyway. Additional key:
+# 'format_html': Boolean indicating whether to treat the article as
+# HTML.
+# Optional. Defaults to False.
+#
+
+ONERROR = {
+ 'UNSUPPORTED_CONTENT_TYPE' : {
+ 'action': 'replace',
+ 'message': 'Article cannot be displayed due to unsupported content type',
+ 'format_html': False,
+ }
+}

Return to:

Send suggestions and report system problems to the System administrator.