Commit 7bb5fd27 by Greg Kempe

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.
parent 46181341
...@@ -109,10 +109,12 @@ def permission_classes(permission_classes): ...@@ -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): ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment