--- a/src/pyams_default_theme/routes.py Tue Jan 08 17:59:46 2019 +0100
+++ b/src/pyams_default_theme/routes.py Wed Jan 09 10:16:22 2019 +0100
@@ -14,7 +14,7 @@
from pyramid.exceptions import NotFound
from pyramid.response import Response
-from pyramid.view import view_config
+from pyramid.view import render_view_to_response, view_config
from pyams_sequence.interfaces import ISequentialIntIds
from pyams_sequence.reference import get_reference_target
@@ -34,7 +34,7 @@
oid = request.matchdict.get('oid')
if oid:
oid = oid.split('::')[0]
- view_name = request.matchdict.get('view')
+ view_name = ''.join(request.matchdict.get('view'))
sequence = get_utility(ISequentialIntIds)
reference = sequence.get_full_oid(oid)
target = get_reference_target(reference)
@@ -49,11 +49,16 @@
if (target is not None) and not IWorkflowPublicationInfo(target).is_visible(request):
target = None
if target is not None:
- response = Response()
- response.status_code = 302
if view_name: # back-office access => last version
- response.location = absolute_url(target, request, '/'.join(view_name))
+ location = absolute_url(target, request, '/'.join(view_name))
else:
- response.location = canonical_url(target, request)
+ location = canonical_url(target, request)
+ if location == request.url:
+ # return view response to avoid infinite redirection!
+ response = render_view_to_response(target, request, view_name)
+ else:
+ response = Response()
+ response.status_code = 302
+ response.location = location
return response
raise NotFound()