# HG changeset patch # User Jeff Hammel # Date 1304907261 25200 # Node ID 3117c5556ecabf7a8fc44f1d041418d44d2530e7 # Parent 9e218743303405bb6d3ff55b8ef2da531c6c63bd update redirectall diff -r 9e2187433034 -r 3117c5556eca redirectall.ini --- 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 diff -r 9e2187433034 -r 3117c5556eca redirectall/dispatcher.py --- 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) diff -r 9e2187433034 -r 3117c5556eca redirectall/factory.py --- 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)