[views] debug-es also displays elastic search response

authorArthur Lutz <arthur.lutz@logilab.fr>
changeset907c8a48b21b
branchdefault
phasedraft
hiddenyes
parent revision#fca664268720 flake8
child revision#f91fb384423a [views] use q=term by default instead of search
files modified by this revision
views.py
# HG changeset patch
# User Arthur Lutz <arthur.lutz@logilab.fr>
# Date 1485337070 -3600
# Wed Jan 25 10:37:50 2017 +0100
# Node ID 907c8a48b21b58cf02416a2bd4aa2c6cdb3e9902
# Parent fca66426872044771f64aba79faad4786f7c5b30
[views] debug-es also displays elastic search response

diff --git a/views.py b/views.py
@@ -118,11 +118,18 @@
1              self.w(u'<pre>')
2              self.w(unicode(json.dumps(search._s.to_dict(), indent=2)))
3              self.w(u'</pre>')
4              self.w(u'<br/>')
5          try:
6 -            return search.execute()
7 +            response = search.execute()
8 +            if 'debug-es' in self._cw.form:
9 +                import json
10 +                self.w(u'<pre>')
11 +                self.w(unicode(json.dumps(response.to_dict(), indent=2)))
12 +                self.w(u'</pre>')
13 +                self.w(u'<br/>')
14 +            return response
15          except NotFoundError:
16              self.w(u'index not found in elasticsearch')
17              return
18 
19      def call(self, **kwargs):