[pyramid] AttributeError when opening an entity view without being connected
Trying to access an entity view without being connected show the following error AttributeError: 'NoneType' object has no attribute 'entity_from_eid'
.
It may be better to redirect the user to the main page to login or showing an understable message.
Output
2021-06-22 16:08:56 - (cubicweb.pyramid.bwcompat) ERROR: 'NoneType' object has no attribute 'entity_from_eid'
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/pyramid/tweens.py", line 41, in excview_tween
response = handler(request)
File "/usr/lib/python3.7/site-packages/cubicweb/pyramid/bwcompat.py", line 208, in __call__
response = self.handler(request)
File "/usr/lib/python3.7/site-packages/pyramid/router.py", line 77, in handle_request
info = routes_mapper(request)
File "/usr/lib/python3.7/site-packages/pyramid/urldispatch.py", line 101, in __call__
if preds and not all((p(info, request) for p in preds)):
File "/usr/lib/python3.7/site-packages/pyramid/urldispatch.py", line 101, in <genexpr>
if preds and not all((p(info, request) for p in preds)):
File "/usr/lib/python3.7/site-packages/cubicweb/pyramid/predicates.py", line 86, in __call__
entity = request.cw_cnx.entity_from_eid(eid)
AttributeError: 'NoneType' object has no attribute 'entity_from_eid'
Steps to reproduce
- Run an instance
- Show a working entity view
- Logged out or remove cookies from web navigator
- Try to show again the previous entity view
System information
- Distribution: GNU/Linux-libre Parabola
- Python version: 3.7.10
- CubicWeb version: 3.31.1