view redirectall/dispatcher.py @ 1:3117c5556eca default tip

update redirectall
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 08 May 2011 19:14:21 -0700
parents 9e2187433034
children
line wrap: on
line source

"""
request dispatcher
"""

from webob import Request, exc

class RedirectAll(object):

    ### class level variables

    def __init__(self, base_url):
        self.base_url = base_url

    ### methods dealing with HTTP
    def __call__(self, environ, start_response):
        request = Request(environ)
        location = self.base_url + request.path
        if request.query_string:
            location += '?' + request.query_string
        response = exc.HTTPMovedPermanently(location=location)
        return response(environ, start_response)