From a07f6963aa6911465814618cb783d61a9cb644c7 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 16 Apr 2011 11:57:41 -0500 Subject: [PATCH] Added a decorator to easily specify allowed HTTP verbs for controller callables --- src/milla/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/milla/__init__.py b/src/milla/__init__.py index 49396ba..c391afb 100644 --- a/src/milla/__init__.py +++ b/src/milla/__init__.py @@ -20,3 +20,18 @@ from webob.exc import * from webob.request import * from webob.response import * from auth.decorators import * + +def allow(*methods): + '''Specify the allowed HTTP verbs for a controller callable + + Example:: + + @milla.allow('GET', 'POST') + def controller(request): + return 'Hello, world!' + ''' + + def wrapper(func): + func.allowed_methods = methods + return func + return wrapper