Added a decorator to easily specify allowed HTTP verbs for controller callables

master
Dustin C. Hatch 2011-04-16 11:57:41 -05:00
parent 4c4ecbfe52
commit a07f6963aa
1 changed files with 15 additions and 0 deletions

View File

@ -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