# HG changeset patch # User Jeff Hammel # Date 1321557993 28800 # Node ID 89047fd9ea8f55e0e9398c1aa602724dea298b33 # Parent 88b611ed2c5ec7741ad0a2513b505ef5237697f0 whitespace diff -r 88b611ed2c5e -r 89047fd9ea8f wsgintegrate/match.py --- a/wsgintegrate/match.py Thu Jul 14 00:05:39 2011 -0700 +++ b/wsgintegrate/match.py Thu Nov 17 11:26:33 2011 -0800 @@ -7,16 +7,16 @@ class RequestMatch(object): """abstract base class for matching requests""" - + def __init__(self, app): self.app = app - + def __call__(self, environ, start_response): """WSGI app""" if not self.condition(environ): raise exc.HTTPNotFound return self.app(environ, start_response) - + def condition(self, environ): """match condition""" return True @@ -32,20 +32,20 @@ class MatchPath(RequestMatch): """match based on PATH INFO""" - + def __init__(self, app, path): RequestMatch.__init__(self, app) self.path = path - + def match(self, path): if path.startswith(self.path): # currently only matches with str.startswith; # different types of matches could be considered return self.path, path[len(self.path):] - + def condition(self, environ): # XXX unused return self.match(environ['PATH_INFO']) is not None - + def __call__(self, environ, start_response): match = self.match(environ['PATH_INFO']) if match is None: @@ -55,12 +55,12 @@ # fix up the environment for downstream applications environ['SCRIPT_NAME'] = script_name environ['PATH_INFO'] = path_info - + return self.app(environ, start_response) class MatchMethod(RequestMatch): """match based on request method""" - + def __init__(self, app, methods): RequestMatch.__init__(self, app) if isinstance(methods, basestring):