def _match_routes(iter_func, request, extra_args=None, extra_kwargs=None):
    method_not_allowed = False
    for route in iter_func():
        try:
            match = route.match(request)
            if match:
                route, args, kwargs = match
                if extra_args:
                    args += extra_args

                if extra_kwargs:
                    kwargs.update(extra_kwargs)

                return route, args, kwargs
        except exc.HTTPMethodNotAllowed:
            method_not_allowed = True

    if method_not_allowed:
        raise exc.HTTPMethodNotAllowed()
Tries to match a route given an iterator.
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/webapp2-2.3/webapp2_extras/routes.py/_match_routes