FIX: Don't default to list in method args

Fixes @list_route and @detail_route so that they don't initialize their `methods` parameter as a list. In some cases the list gets cleared, and the result is that default parameter is now empty, and may get reused unexpectedly.
This commit is contained in:
Greg Kempe 2015-02-04 16:03:03 +02:00
parent 46181341d5
commit 7bb5fd270d

View File

@ -109,10 +109,12 @@ def permission_classes(permission_classes):
return decorator return decorator
def detail_route(methods=['get'], **kwargs): def detail_route(methods=None, **kwargs):
""" """
Used to mark a method on a ViewSet that should be routed for detail requests. Used to mark a method on a ViewSet that should be routed for detail requests.
""" """
if methods is None:
methods = ['get']
def decorator(func): def decorator(func):
func.bind_to_methods = methods func.bind_to_methods = methods
func.detail = True func.detail = True
@ -121,10 +123,12 @@ def detail_route(methods=['get'], **kwargs):
return decorator return decorator
def list_route(methods=['get'], **kwargs): def list_route(methods=None, **kwargs):
""" """
Used to mark a method on a ViewSet that should be routed for list requests. Used to mark a method on a ViewSet that should be routed for list requests.
""" """
if methods is None:
methods = ['get']
def decorator(func): def decorator(func):
func.bind_to_methods = methods func.bind_to_methods = methods
func.detail = False func.detail = False