14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """cubicweb server sources support""" |
18 """cubicweb server sources support""" |
|
19 from __future__ import print_function |
19 |
20 |
20 __docformat__ = "restructuredtext en" |
21 __docformat__ = "restructuredtext en" |
21 |
22 |
22 from time import time |
23 from time import time |
23 from logging import getLogger |
24 from logging import getLogger |
34 |
35 |
35 |
36 |
36 def dbg_st_search(uri, union, varmap, args, cachekey=None, prefix='rql for'): |
37 def dbg_st_search(uri, union, varmap, args, cachekey=None, prefix='rql for'): |
37 if server.DEBUG & server.DBG_RQL: |
38 if server.DEBUG & server.DBG_RQL: |
38 global t |
39 global t |
39 print ' %s %s source: %s' % (prefix, uri, repr(union.as_string())) |
40 print(' %s %s source: %s' % (prefix, uri, repr(union.as_string()))) |
40 t = time() |
41 t = time() |
41 if varmap: |
42 if varmap: |
42 print ' using varmap', varmap |
43 print(' using varmap', varmap) |
43 if server.DEBUG & server.DBG_MORE: |
44 if server.DEBUG & server.DBG_MORE: |
44 print ' args', repr(args) |
45 print(' args', repr(args)) |
45 print ' cache key', cachekey |
46 print(' cache key', cachekey) |
46 print ' solutions', ','.join(str(s.solutions) |
47 print(' solutions', ','.join(str(s.solutions) |
47 for s in union.children) |
48 for s in union.children)) |
48 # return true so it can be used as assertion (and so be killed by python -O) |
49 # return true so it can be used as assertion (and so be killed by python -O) |
49 return True |
50 return True |
50 |
51 |
51 def dbg_results(results): |
52 def dbg_results(results): |
52 if server.DEBUG & server.DBG_RQL: |
53 if server.DEBUG & server.DBG_RQL: |
53 if len(results) > 10: |
54 if len(results) > 10: |
54 print ' -->', results[:10], '...', len(results), |
55 print(' -->', results[:10], '...', len(results), end=' ') |
55 else: |
56 else: |
56 print ' -->', results, |
57 print(' -->', results, end=' ') |
57 print 'time: ', time() - t |
58 print('time: ', time() - t) |
58 # return true so it can be used as assertion (and so be killed by python -O) |
59 # return true so it can be used as assertion (and so be killed by python -O) |
59 return True |
60 return True |
60 |
61 |
61 |
62 |
62 class AbstractSource(object): |
63 class AbstractSource(object): |