[pyramid/debug] on every request display request path and selected controller

This will display lines like:

2019-06-12 16:26:57 - (cubicweb.pyramid.bwcompat) INFO: REQUEST [view] '/wiki/334037' selected controller <cubicweb.web.views.basecontrollers.ViewController object at 0x7f133802ae90> at /root/.virtualenvs/abreton/local/lib/python2.7/site-packages/cubicweb/web/views/basecontrollers.py:120

2019-06-12 16:26:59 - (cubicweb.pyramid.bwcompat) INFO: REQUEST [data] '/data/ea5eb3b6f89fba0ff4b671093c88d3dd/images/cartouche-mur.jpg' selected controller <cubicweb.web.views.staticcontrollers.DataController object at 0x7f1332a84d50> at /root/.virtualenvs/abreton/local/lib/python2.7/site-packages/cubicweb/web/views/staticcontrollers.py:179

The make debugging easier as this isn't done already. Most other web frameworks do something similar for the developper to be able to understand what is happening right now.

Closes #17219741

authorLaurent Peuch <cortex@worlddomination.be>
changeset90348f847b4b
branchdefault
phasepublic
hiddenno
parent revision#6e98699d3a9a [logging/debug] move transaction operations logs from self.debug to DBG_OPS
child revision#ca698656251c Add a migration function in order to relocate bfss, #e94573473c1b Add a Jenkinsfile
files modified by this revision
cubicweb/pyramid/bwcompat.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1560362280 -7200
# Wed Jun 12 19:58:00 2019 +0200
# Node ID 90348f847b4b9e9c521fbd97add42b02f895a4b7
# Parent 6e98699d3a9a4e7427a67d6f82639157e0854111
[pyramid/debug] on every request display request path and selected controller

This will display lines like:

2019-06-12 16:26:57 - (cubicweb.pyramid.bwcompat) INFO: REQUEST [view] '/wiki/334037' selected controller <cubicweb.web.views.basecontrollers.ViewController object at 0x7f133802ae90> at /root/.virtualenvs/abreton/local/lib/python2.7/site-packages/cubicweb/web/views/basecontrollers.py:120

2019-06-12 16:26:59 - (cubicweb.pyramid.bwcompat) INFO: REQUEST [data] '/data/ea5eb3b6f89fba0ff4b671093c88d3dd/images/cartouche-mur.jpg' selected controller <cubicweb.web.views.staticcontrollers.DataController object at 0x7f1332a84d50> at /root/.virtualenvs/abreton/local/lib/python2.7/site-packages/cubicweb/web/views/staticcontrollers.py:179

The make debugging easier as this isn't done already. Most other web frameworks
do something similar for the developper to be able to understand what is
happening right now.

Closes #17219741

diff --git a/cubicweb/pyramid/bwcompat.py b/cubicweb/pyramid/bwcompat.py
@@ -19,10 +19,11 @@
1  # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
2 
3  """Backward compatibility layer for CubicWeb to run as a Pyramid application."""
4 
5  import sys
6 +import inspect
7  import logging
8 
9  from pyramid import security
10  from pyramid import tweens
11  from pyramid.httpexceptions import HTTPSeeOther
@@ -86,11 +87,16 @@
12                                                                     req.path)
13 
14                      try:
15                          controller = vreg['controllers'].select(
16                              ctrlid, req, appli=self.appli)
17 +                        log.info("REQUEST [%s] '%s' selected controller %s at %s:%s",
18 +                                 ctrlid, req.path, controller,
19 +                                 inspect.getsourcefile(controller.__class__),
20 +                                 inspect.getsourcelines(controller.__class__)[1])
21                      except cubicweb.NoSelectableObject:
22 +                        log.warn("WARNING '%s' unauthorized request", req.path)
23                          raise httpexceptions.HTTPUnauthorized(
24                              req._('not authorized'))
25 
26                      req.update_search_state()
27                      content = controller.publish(rset=rset)