[views] debug-es also displays elastic search response

authorArthur Lutz <arthur.lutz@logilab.fr>
changesetcf0931e576e2
branchdefault
phasepublic
hiddenno
parent revision#f859339123c8 flake8
child revision#9fd50d807896 [views] use q=term by default instead of search (closes #17049619)
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 cf0931e576e2d4868efb1e72294b683d06bb4718
# Parent f859339123c83b5b28da1aa39590d13aa69bd68e
[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):