(self, environ)
Return a (target, url_agrs) tuple or raise HTTPError(400/404/405).
Return a (target, url_agrs) tuple or raise HTTPError(400/404/405).
Return a ( target url_agrs ) tuple or raise HTTPError ( 400 / 404 / 405 ) .
def match(self, environ):
        ''' Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). '''
        path, targets, urlargs = environ['PATH_INFO'] or '/', None, {}
        if path in self.static:
            targets = self.static[path]
        else:
            for combined, rules in self.dynamic:
                match = combined.match(path)
                if not match: continue
                getargs, targets = rules[match.lastindex - 1]
                urlargs = getargs(path) if getargs else {}
                break

        if not targets:
            raise HTTPError(404, "Not found: " + repr(environ['PATH_INFO']))
        method = environ['REQUEST_METHOD'].upper()
        if method in targets:
            return targets[method], urlargs
        if method == 'HEAD' and 'GET' in targets:
            return targets['GET'], urlargs
        if 'ANY' in targets:
            return targets['ANY'], urlargs
        allowed = [verb for verb in targets if verb != 'ANY']
        if 'GET' in allowed and 'HEAD' not in allowed:
            allowed.append('HEAD')
        raise HTTPError(405, "Method not allowed.", Allow=",".join(allowed))
def match ( self , environ ) : path , targets , urlargs = environ [ 'PATH_INFO' ] or '/' , None , { } if path in self . static : targets = self . static [ path ] else : for combined , rules in self . dynamic : match = combined . match ( path ) if not match : continue getargs , targets = rules [ match . lastindex - 1 ] urlargs = getargs ( path ) if getargs else { } break if not targets : raise HTTPError ( 404 , "Not found: " + repr ( environ [ 'PATH_INFO' ] ) ) method = environ [ 'REQUEST_METHOD' ] . upper ( ) if method in targets : return targets [ method ] , urlargs if method == 'HEAD' and 'GET' in targets : return targets [ 'GET' ] , urlargs if 'ANY' in targets : return targets [ 'ANY' ] , urlargs allowed = [ verb for verb in targets if verb != 'ANY' ] if 'GET' in allowed and 'HEAD' not in allowed : allowed . append ( 'HEAD' ) raise HTTPError ( 405 , "Method not allowed." , Allow = "," . join ( allowed ) )