103 # XXX I don't think it makes sens to catch this ex here (cdevienne) |
104 # XXX I don't think it makes sens to catch this ex here (cdevienne) |
104 |
105 |
105 return request.response |
106 return request.response |
106 |
107 |
107 |
108 |
|
109 class TweenHandler(object): |
|
110 def __init__(self, handler, registry): |
|
111 self.handler = handler |
|
112 self.cwhandler = registry['cubicweb.handler'] |
|
113 |
|
114 def __call__(self, request): |
|
115 try: |
|
116 response = self.handler(request) |
|
117 except httpexceptions.HTTPNotFound: |
|
118 response = self.cwhandler(request) |
|
119 return response |
|
120 |
|
121 |
108 def includeme(config): |
122 def includeme(config): |
109 # Set up a defaut route to handle non-catched urls. |
123 # Set up a tween app that will handle the request if the main application |
|
124 # raises a HTTPNotFound exception. |
110 # This is to keep legacy compatibility for cubes that makes use of the |
125 # This is to keep legacy compatibility for cubes that makes use of the |
111 # cubicweb controllers. |
126 # cubicweb controllers. |
112 cwconfig = config.registry['cubicweb.config'] |
127 cwconfig = config.registry['cubicweb.config'] |
113 repository = config.registry['cubicweb.repository'] |
128 repository = config.registry['cubicweb.repository'] |
114 cwappli = CubicWebPublisher( |
129 cwappli = CubicWebPublisher( |
115 repository, cwconfig, |
130 repository, cwconfig, |
116 session_handler_fact=PyramidSessionHandler) |
131 session_handler_fact=PyramidSessionHandler) |
117 handler = CubicWebPyramidHandler(cwappli) |
132 cwhandler = CubicWebPyramidHandler(cwappli) |
118 |
133 |
119 config.registry['cubicweb.appli'] = cwappli |
134 config.registry['cubicweb.appli'] = cwappli |
120 config.registry['cubicweb.handler'] = handler |
135 config.registry['cubicweb.handler'] = cwhandler |
121 |
136 |
122 config.add_route('catchall', pattern='*path') |
137 config.add_tween( |
123 config.add_view(handler, route_name='catchall') |
138 'pyramid_cubicweb.bwcompat.TweenHandler', under=tweens.EXCVIEW) |