comparison 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
comparison
equal deleted inserted replaced
0:9e2187433034 1:3117c5556eca
1 """ 1 """
2 request dispatcher 2 request dispatcher
3 """ 3 """
4 4
5 from handlers import Get, Post
6 from webob import Request, exc 5 from webob import Request, exc
7 6
8 class Dispatcher(object): 7 class RedirectAll(object):
9 8
10 ### class level variables 9 ### class level variables
11 10
12 def __init__(self, base_url): 11 def __init__(self, base_url):
13 self.base_url = base_url 12 self.base_url = base_url
14 13
15 ### methods dealing with HTTP 14 ### methods dealing with HTTP
16 def __call__(self, environ, start_response): 15 def __call__(self, environ, start_response):
17 request = Request(environ) 16 request = Request(environ)
18 import pdb; pdb.set_trace() 17 location = self.base_url + request.path
19 return res(environ, start_response) 18 if request.query_string:
19 location += '?' + request.query_string
20 response = exc.HTTPMovedPermanently(location=location)
21 return response(environ, start_response)