Mercurial > hg > redirectall
changeset 1:3117c5556eca default tip
update redirectall
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 08 May 2011 19:14:21 -0700 |
parents | 9e2187433034 |
children | |
files | redirectall.ini redirectall/dispatcher.py redirectall/factory.py |
diffstat | 3 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/redirectall.ini Sun May 08 18:28:26 2011 -0700 +++ b/redirectall.ini Sun May 08 19:14:21 2011 -0700 @@ -19,4 +19,4 @@ [app:redirectall] paste.app_factory = redirectall.factory:factory -redirectall.base_url = http://brasstacks.mozilla.com/toolbox/ \ No newline at end of file +redirectall.base_url = http://brasstacks.mozilla.com/toolbox \ No newline at end of file
--- a/redirectall/dispatcher.py Sun May 08 18:28:26 2011 -0700 +++ b/redirectall/dispatcher.py Sun May 08 19:14:21 2011 -0700 @@ -2,10 +2,9 @@ request dispatcher """ -from handlers import Get, Post from webob import Request, exc -class Dispatcher(object): +class RedirectAll(object): ### class level variables @@ -15,5 +14,8 @@ ### methods dealing with HTTP def __call__(self, environ, start_response): request = Request(environ) - import pdb; pdb.set_trace() - return res(environ, start_response) + location = self.base_url + request.path + if request.query_string: + location += '?' + request.query_string + response = exc.HTTPMovedPermanently(location=location) + return response(environ, start_response)
--- a/redirectall/factory.py Sun May 08 18:28:26 2011 -0700 +++ b/redirectall/factory.py Sun May 08 19:14:21 2011 -0700 @@ -1,5 +1,4 @@ -from dispatcher import Dispatcher -from paste.httpexceptions import HTTPExceptionHandler +from dispatcher import RedirectAll def factory(global_conf, **app_conf): """create a webob view and wrap it in middleware""" @@ -7,6 +6,5 @@ args = dict([(key.split(keystr, 1)[-1], value) for key, value in app_conf.items() if key.startswith(keystr) ]) - app = Dispatcher(**args) - return HTTPExceptionHandler(app) + return RedirectAll(**args)