From 6265ef31bf57749196cd7759b83880f81f30e616 Mon Sep 17 00:00:00 2001 From: lizheao Date: Mon, 1 May 2017 22:35:32 +0800 Subject: [PATCH] recovery the format --- sanic/blueprints.py | 10 ---------- sanic/exceptions.py | 2 -- 2 files changed, 12 deletions(-) diff --git a/sanic/blueprints.py b/sanic/blueprints.py index 37c41a78..b4ca5f6b 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -95,7 +95,6 @@ class Blueprint: :param uri: endpoint at which the route will be accessible. :param methods: list of acceptable HTTP methods. """ - def decorator(handler): if isinstance(handler, MethodType): raise SanicTypeException("You can`t add a instance " @@ -104,7 +103,6 @@ class Blueprint: route = FutureRoute(handler, uri, methods, host, strict_slashes) self.routes.append(route) return handler - return decorator def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None, @@ -142,12 +140,10 @@ class Blueprint: :param uri: endpoint at which the route will be accessible. """ - def decorator(handler): route = FutureRoute(handler, uri, [], host, strict_slashes) self.websocket_routes.append(route) return handler - return decorator def add_websocket_route(self, handler, uri, host=None): @@ -166,21 +162,17 @@ class Blueprint: :param event: Event to listen to. """ - def decorator(listener): self.listeners[event].append(listener) return listener - return decorator def middleware(self, *args, **kwargs): """Create a blueprint middleware from a decorated function.""" - def register_middleware(_middleware): future_middleware = FutureMiddleware(_middleware, args, kwargs) self.middlewares.append(future_middleware) return _middleware - # Detect which way this was called, @middleware or @middleware('AT') if len(args) == 1 and len(kwargs) == 0 and callable(args[0]): middleware = args[0] @@ -191,12 +183,10 @@ class Blueprint: def exception(self, *args, **kwargs): """Create a blueprint exception from a decorated function.""" - def decorator(handler): exception = FutureException(handler, args, kwargs) self.exceptions.append(exception) return handler - return decorator def static(self, uri, file_or_directory, *args, **kwargs): diff --git a/sanic/exceptions.py b/sanic/exceptions.py index 0af34390..f0971e18 100644 --- a/sanic/exceptions.py +++ b/sanic/exceptions.py @@ -106,8 +106,6 @@ class SanicException(Exception): class SanicTypeException(Exception): pass - - class NotFound(SanicException): status_code = 404