summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2010-02-09 15:02:39 +0000
committerLuke Plant <L.Plant.98@cantab.net>2010-02-09 15:02:39 +0000
commit4bff19463361927ff752929da1bc04e9aa1c2e72 (patch)
treef4f31666ba7dff59b4925ca390bf139f2a3c256b /docs
parentedb6d753a85d8548d9735b6f253a4a5d9a749c75 (diff)
Fixed #12804 - regression with decorating admin views.
This is a BACKWARDS INCOMPATIBLE change, because it removes the flawed 'auto_adapt_to_methods' decorator, and replaces it with 'method_decorator' which must be applied manually when necessary, as described in the 1.2 release notes. For users of 1.1 and 1.0, this affects the decorators: * login_required * permission_required * user_passes_test For those following trunk, this also affects: * csrf_protect * anything created with decorator_from_middleware If a decorator does not depend on the signature of the function it is supposed to decorate (for example if it only does post-processing of the result), it will not be affected. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.2.txt49
1 files changed, 49 insertions, 0 deletions
diff --git a/docs/releases/1.2.txt b/docs/releases/1.2.txt
index f4826787c2..f8bb3c8bf3 100644
--- a/docs/releases/1.2.txt
+++ b/docs/releases/1.2.txt
@@ -251,6 +251,55 @@ incompatibilities, especially if you are storing comma or semi-colon in
cookies and have javascript code that parses and manipulates cookie values
client-side.
+``user_passes_test``, ``login_required`` and ``permission_required``
+--------------------------------------------------------------------
+
+``django.contrib.auth.decorators`` provides the decorators ``login_required``,
+``permission_required`` and ``user_passes_test``. Previously it was possible to
+use these decorators both on functions (where the first argument is 'request')
+and on methods (where the first argument is 'self', and the second argument is
+'request'). However, we have found that the trick which enabled this is
+flawed. It only works in limited circumstances, and produces errors that are
+very difficult to debug when it does not work.
+
+For this reason, the 'auto adapt' behaviour has been removed, and if you are
+using these decorators on methods, you will need to manually apply
+:func:`django.utils.decorators.method_decorator` to convert the decorator to one
+that works with methods. You would change code from this::
+
+ class MyClass(object):
+
+ @login_required
+ def my_view(self, request):
+ pass
+
+to this::
+
+ from django.utils.decorators import method_decorator
+
+ class MyClass(object):
+
+ @method_decorator(login_required)
+ def my_view(self, request):
+ pass
+
+or::
+
+ from django.utils.decorators import method_decorator
+
+ login_required_m = method_decorator(login_required)
+
+ class MyClass(object):
+
+ @login_required_m
+ def my_view(self, request):
+ pass
+
+For those following trunk, this change also applies to other decorators
+introduced since 1.1, including ``csrf_protect``, ``cache_control`` and anything
+created using ``decorator_from_middleware``.
+
+
.. _deprecated-features-1.2:
Features deprecated in 1.2