Skip to content

Instantly share code, notes, and snippets.

@href href/
Last active Sep 28, 2017

What would you like to do?
Internal redirects in Morepath
""" Simple redirects for renamed paths using a generic redirect model.
For static paths:
class OldPathRedirect(Redirect):
to = '/new-path'
For wildcard paths (e.g. /old-pages/my-page to /new-pages/my-page):
@App.path('/old-path', absorb=True)
class OldPagesRedirect(Redirect):
to = '/new-pages
import morepath
class App(morepath.App):
class Redirect(object):
to = None
def __init__(self, absorb=None):
assert and not'/')
if absorb: += '/' + absorb
def view_redirect(self, request):
return morepath.redirect(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.