From 36d519026f3b02772d961820449f8810a2c9b19c Mon Sep 17 00:00:00 2001 From: Suby Raman Date: Fri, 3 Feb 2017 10:12:33 -0500 Subject: [PATCH] reject unnamed handlers --- sanic/router.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sanic/router.py b/sanic/router.py index c065ffd4..24d0438f 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -196,7 +196,7 @@ class Router: handler_name = '{}.{}'.format( handler.__blueprintname__, handler.__name__) else: - handler_name = handler.__name__ + handler_name = getattr(handler, '__name__', None) route = Route( handler=handler, methods=methods, pattern=pattern, @@ -245,6 +245,9 @@ class Router: :param view_name: string of view name to search by :return: tuple containing (uri, Route) """ + if not view_name: + return (None, None) + for uri, route in self.routes_all.items(): if route.name == view_name: return uri, route