Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
longhotsummer committed Feb 4, 2015
commit 7bb5fd270da98d8957efb4bf0e4bd4679ddbcf5f
8 changes: 6 additions & 2 deletions rest_framework/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ def decorator(func):
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.
"""
if methods is None:
methods = ['get']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline here, also let's use the methods = ['get'] if (methods is None) else methods style.

def decorator(func):
func.bind_to_methods = methods
func.detail = True
Expand All @@ -121,10 +123,12 @@ def decorator(func):
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.
"""
if methods is None:
methods = ['get']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline here, also let's use the methods = ['get'] if (methods is None) else methods style.

def decorator(func):
func.bind_to_methods = methods
func.detail = False
Expand Down