aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2013-08-19 21:02:22 +0100
committerTom Christie2013-08-19 21:02:22 +0100
commit8acee2e626746f3096c49b3ebb13aaf7dc882917 (patch)
treea30d67133916962da2b96bc75bf2b2234dbcdda4
parent4292cc18fa3e4b3f5e67c02c3780cdcbf901a0a1 (diff)
downloaddjango-rest-framework-8acee2e626746f3096c49b3ebb13aaf7dc882917.tar.bz2
Commenting link/action decorators as pending deprecation
-rw-r--r--rest_framework/decorators.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py
index 1ca176f2..18e41a18 100644
--- a/rest_framework/decorators.py
+++ b/rest_framework/decorators.py
@@ -108,53 +108,54 @@ def permission_classes(permission_classes):
return decorator
-def link(**kwargs):
+def detail_route(methods=['get'], **kwargs):
"""
- Used to mark a method on a ViewSet that should be routed for detail GET requests.
+ Used to mark a method on a ViewSet that should be routed for detail requests.
"""
- msg = 'link is pending deprecation. Use detail_route instead.'
- warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
def decorator(func):
- func.bind_to_methods = ['get']
+ func.bind_to_methods = methods
func.detail = True
func.kwargs = kwargs
return func
return decorator
-def action(methods=['post'], **kwargs):
+def list_route(methods=['get'], **kwargs):
"""
- Used to mark a method on a ViewSet that should be routed for detail POST requests.
+ Used to mark a method on a ViewSet that should be routed for list requests.
"""
- msg = 'action is pending deprecation. Use detail_route instead.'
- warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
def decorator(func):
func.bind_to_methods = methods
- func.detail = True
+ func.detail = False
func.kwargs = kwargs
return func
return decorator
+# These are now pending deprecation, in favor of `detail_route` and `list_route`.
-def detail_route(methods=['get'], **kwargs):
+def link(**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 GET requests.
"""
+ msg = 'link is pending deprecation. Use detail_route instead.'
+ warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
def decorator(func):
- func.bind_to_methods = methods
+ func.bind_to_methods = ['get']
func.detail = True
func.kwargs = kwargs
return func
return decorator
-def list_route(methods=['get'], **kwargs):
+def action(methods=['post'], **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 detail POST requests.
"""
+ msg = 'action is pending deprecation. Use detail_route instead.'
+ warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
def decorator(func):
func.bind_to_methods = methods
- func.detail = False
+ func.detail = True
func.kwargs = kwargs
return func
- return decorator
+ return decorator \ No newline at end of file