Not found view doesn't work on Pyramid using traversal -
i'm using pyramid (1.5.7) + traversal , following documentation i've tried possible ways "not found exception view" working.
from pyramid.view import notfound_view_config,forbidden_view_config, view_config @notfound_view_config(renderer="error/not_found.jinja2") def not_found_view(request): request.response.status = 404 return {} @forbidden_view_config(renderer="error/forbidden.jinja2") def forbidden_view(request): return {}
using contexts:
from pyramid.view import view_config pyramid.httpexceptions import httpforbidden, httpunauthorized @view_config(context=httpnotfound, renderer="error/not_found.jinja2") def not_found_view(request): request.response.status = 404 return {} @view_config(context=httpforbidden, renderer="error/forbidden.jinja2") def forbidden_view(request): return {}
i'm using scan mode, i've tried adding custom function configuration:
def main(globals, **settings): config = configurator() config.add_notfound_view(notfound)
not luck either, time getting following unhandled exception:
raise httpnotfound(msg) pyramid.httpexceptions.httpnotfound: /example-url
ouch... bad! using tween preventing pyramid load exceptions:
def predispatch_factory(handler, registry): # one-time configuration code goes here def predispatch(request): # code executed each request before # actual application code goes here response = handler(request) # code executed each request after # actual application code goes here return response return predispatch
still don't know why after removing tween seems work expected.
Comments
Post a Comment