def match(self, request): regex_list = [self.regex] method = getattr(self.handler, self.handler_method, None) if method: default_args = getattr(inspect.getargspec(method), 'defaults', None) or [] if len(default_args) > 0: split = self.regex.pattern.split('\/') for i in xrange(1, len(default_args)+1): pattern = '\/'.join(split[:-i]) + '$' regex_list.append(re.compile(pattern, self.regex.flags)) for regex in regex_list: match = regex.match(urllib.unquote(request.path)) if match: break if not match or self.schemes and request.scheme not in self.schemes: return None if self.methods and request.method not in self.methods: # This will be caught by the router, so routes with different # methods can be tried. raise webapp2.exc.HTTPMethodNotAllowed() args, kwargs = webapp2._get_route_variables(match, self.defaults.copy()) return self, args, kwargs
def match(self, request): # Use SERVER_NAME to ignore port number that comes with request.host? # host_match = self.regex.match(request.host.split(':', 1)[0]) host_match = self.regex.match(request.environ["SERVER_NAME"]) if host_match: args, kwargs = webapp2._get_route_variables(host_match) return _match_routes(self.get_match_children, request, None, kwargs)
def match(self, request): # Use SERVER_NAME to ignore port number that comes with request.host? # host_match = self.regex.match(request.host.split(':', 1)[0]) host_match = self.regex.match(request.environ['SERVER_NAME']) if host_match: args, kwargs = webapp2._get_route_variables(host_match) return _match_routes(self.get_match_children, request, None, kwargs)
def match(self, request): # Use SERVER_NAME to ignore port number that comes with request.host? # host_match = self.regex.match(request.host.split(':', 1)[0]) host_match = self.regex.match(request.environ['SERVER_NAME']) if host_match: method_not_allowed = False for route in self.get_match_children(): try: match = route.match(request) if match: args, kwargs = webapp2._get_route_variables(host_match) match[2].update(kwargs) return match except exc.HTTPMethodNotAllowed: method_not_allowed = True if method_not_allowed: raise exc.HTTPMethodNotAllowed()