Skip to content

Instantly share code, notes, and snippets.

@href
Last active September 28, 2017 09:13
Show Gist options
  • Select an option

  • Save href/03bcb7ab78ab55c65af9b7e7f85479bf to your computer and use it in GitHub Desktop.

Select an option

Save href/03bcb7ab78ab55c65af9b7e7f85479bf to your computer and use it in GitHub Desktop.

Revisions

  1. href revised this gist Sep 28, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion app.py
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ def __init__(self, absorb=None):
    assert self.to and not self.to.endswith('/')

    if absorb:
    self.to + '/' + absorb
    self.to += '/' + absorb

    @App.view(model=Redirect)
    def view_redirect(self, request):
  2. href revised this gist Sep 28, 2017. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions app.py
    Original file line number Diff line number Diff line change
    @@ -30,10 +30,3 @@ def __init__(self, absorb=None):
    def view_redirect(self, request):
    return morepath.redirect(self.to)

    @App.path(path='/benutzerverwaltung')
    class BenutzerverwaltungRedirect(Redirect):
    to = '/usermanagement'

    @App.path(path='/themen', absorb=True)
    class ThemenRedirect(Redirect):
    to = '/topics'
  3. href revised this gist Sep 28, 2017. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions app.py
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,13 @@
    """ Simple redirects for renamed paths using a generic redirect model.
    Usage:
    For static paths:
    # for static paths:
    @App.path('/old-path')
    class OldPathRedirect(Redirect):
    to = '/new-path'
    # for wildcard paths (e.g. /old-pages/my-page to /new-pages/my-page)
    # (notice the absorb paramater)
    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
  4. href revised this gist Sep 28, 2017. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions app.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,18 @@
    """ Simple redirects for renamed paths using a generic redirect model.
    Usage:
    # for static paths:
    @App.path('/old-path')
    class OldPathRedirect(Redirect):
    to = '/new-path'
    # for wildcard paths (e.g. /old-pages/my-page to /new-pages/my-page)
    # (notice the absorb paramater)
    @App.path('/old-path', absorb=True)
    class OldPagesRedirect(Redirect):
    to = '/new-pages
    """
    import morepath

    class App(morepath.App):
  5. href created this gist Sep 28, 2017.
    25 changes: 25 additions & 0 deletions app.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    import morepath

    class App(morepath.App):
    pass

    class Redirect(object):
    to = None

    def __init__(self, absorb=None):
    assert self.to and not self.to.endswith('/')

    if absorb:
    self.to + '/' + absorb

    @App.view(model=Redirect)
    def view_redirect(self, request):
    return morepath.redirect(self.to)

    @App.path(path='/benutzerverwaltung')
    class BenutzerverwaltungRedirect(Redirect):
    to = '/usermanagement'

    @App.path(path='/themen', absorb=True)
    class ThemenRedirect(Redirect):
    to = '/topics'