Mercurial > hg > wsgintegrate
comparison wsgintegrate/dispatcher.py @ 0:ec815b7cb142
initial commit of wsgintegrate
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 07 Jun 2011 08:03:09 -0700 |
parents | |
children | 88b611ed2c5e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ec815b7cb142 |
---|---|
1 """ | |
2 multi-application dispatcher for WSGI apps | |
3 """ | |
4 | |
5 from webob import Request | |
6 from webob import exc | |
7 | |
8 class Dispatcher(object): | |
9 | |
10 def __init__(self, *apps): | |
11 self.apps = apps | |
12 self.codes = set([404]) | |
13 | |
14 def __call__(self, environ, start_response): | |
15 request = Request(environ) | |
16 for app in self.apps: | |
17 try: | |
18 response = request.get_response(app) | |
19 if response.status_int in self.codes: | |
20 continue | |
21 break | |
22 except exc.HTTPNotFound: | |
23 continue | |
24 else: | |
25 response = exc.HTTPNotFound() | |
26 return response(environ, start_response) |