Vinoth
Vinoth

Reputation: 21

How to redirect 404 NOTFOUND Error page in Pyramid using Traversal?

I use

def notfound(request):
    return HTTPFound(location="/login")

def main(globals, **settings):
    config = Configurator()
    config.add_notfound_view(notfound)

But it doesn't work in my traversal based project. How to implement it in traversal? Am I right or have any other specific way to do the redirection

Upvotes: 0

Views: 480

Answers (1)

Sascha Gottfried
Sascha Gottfried

Reputation: 3329

Pyramid returns the results of "Not Found" view if no route matches or traversal view lookup finds no matching view type. If your setup does not redirect, traversal found any context. If this is not working anyway, start a new pyramid application to test these simple concepts isolated.

Look at these pages in documentation. It is very well explained.

To debug your special case, enable pyramid.debug_notfound environment setting and learn to use pyramid_debugtoolbar to improve your debug capabilities.

Usually you want to use a "Forbidden View" to redirect to login pages.

Learn about traversal algorithm - my recommendation: print Model Graph Traversal and expose it near to your working desk.

Upvotes: 1

Related Questions