cubicweb/web/application.py
changeset 12043 b8d2e6b9f548
parent 11913 4516c3956d46
child 12050 1c7be7b62823
equal deleted inserted replaced
12042:5e64a98572de 12043:b8d2e6b9f548
    75     return wrapper
    75     return wrapper
    76 
    76 
    77 
    77 
    78 @contextmanager
    78 @contextmanager
    79 def anonymized_request(req):
    79 def anonymized_request(req):
       
    80     from cubicweb.web.views.authentication import Session
       
    81 
    80     orig_cnx = req.cnx
    82     orig_cnx = req.cnx
    81     anon_cnx = anonymous_cnx(orig_cnx.session.repo)
    83     anon_cnx = anonymous_cnx(orig_cnx.session.repo)
    82     try:
    84     try:
    83         with anon_cnx:
    85         with anon_cnx:
       
    86             # web request expect a session attribute on cnx referencing the web session
       
    87             anon_cnx.session = Session(orig_cnx.session.repo, anon_cnx.user)
    84             req.set_cnx(anon_cnx)
    88             req.set_cnx(anon_cnx)
    85             yield req
    89             yield req
    86     finally:
    90     finally:
    87         req.set_cnx(orig_cnx)
    91         req.set_cnx(orig_cnx)
    88 
    92