Author: lukeplant
Date: 2010-02-09 13:37:08 -0600 (Tue, 09 Feb 2010)
New Revision: 12400
Modified:
django/trunk/docs/howto/custom-template-tags.txt
django/trunk/docs/topics/auth.txt
django/trunk/docs/topics/cache.txt
Log:
Removed docs that assume developer might be using Python < 2.4
Modified: django/trunk/docs/howto/custom-template-tags.txt
===================================================================
--- django/trunk/docs/howto/custom-template-tags.txt 2010-02-09 15:02:39 UTC
(rev 12399)
+++ django/trunk/docs/howto/custom-template-tags.txt 2010-02-09 19:37:08 UTC
(rev 12400)
@@ -138,8 +138,7 @@
2. The compilation function -- a Python function (not the name of the
function as a string).
-If you're using Python 2.4 or above, you can use ``register.filter()`` as a
-decorator instead::
+You can use ``register.filter()`` as a decorator instead::
@register.filter(name='cut')
@stringfilter
@@ -557,8 +556,7 @@
2. The compilation function -- a Python function (not the name of the
function as a string).
-As with filter registration, it is also possible to use this as a decorator, in
-Python 2.4 and above::
+As with filter registration, it is also possible to use this as a decorator::
@register.tag(name="current_time")
def do_current_time(parser, token):
@@ -657,7 +655,7 @@
register.simple_tag(current_time)
-In Python 2.4, the decorator syntax also works::
+The decorator syntax also works::
@register.simple_tag
def current_time(format_string):
@@ -738,8 +736,7 @@
# Here, register is a django.template.Library instance, as before
register.inclusion_tag('results.html')(show_results)
-As always, Python 2.4 decorator syntax works as well, so we could have
-written::
+As always, decorator syntax works as well, so we could have written::
@register.inclusion_tag('results.html')
def show_results(poll):
Modified: django/trunk/docs/topics/auth.txt
===================================================================
--- django/trunk/docs/topics/auth.txt 2010-02-09 15:02:39 UTC (rev 12399)
+++ django/trunk/docs/topics/auth.txt 2010-02-09 19:37:08 UTC (rev 12400)
@@ -696,36 +696,19 @@
from django.contrib.auth.decorators import login_required
- def my_view(request):
- # ...
- my_view = login_required(my_view)
-
- Here's an equivalent example, using the more compact decorator syntax
- introduced in Python 2.4::
-
- from django.contrib.auth.decorators import login_required
-
@login_required
def my_view(request):
- # ...
+ ...
:func:`~django.contrib.auth.decorators.login_required` also takes an
optional ``redirect_field_name`` parameter. Example::
- from django.contrib.auth.decorators import login_required
- def my_view(request):
- # ...
- my_view = login_required(redirect_field_name='redirect_to')(my_view)
-
- Again, an equivalent example of the more compact decorator syntax
- introduced in Python 2.4::
-
from django.contrib.auth.decorators import login_required
@login_required(redirect_field_name='redirect_to')
def my_view(request):
- # ...
+ ...
:func:`~django.contrib.auth.decorators.login_required` does the following:
@@ -1058,23 +1041,15 @@
from django.contrib.auth.decorators import user_passes_test
+ @user_passes_test(lambda u: u.has_perm('polls.can_vote'))
def my_view(request):
- # ...
- my_view = user_passes_test(lambda u:
u.has_perm('polls.can_vote'))(my_view)
+ ...
We're using this particular test as a relatively simple example. However,
if you just want to test whether a permission is available to a user, you
can use the :func:`~django.contrib.auth.decorators.permission_required()`
decorator, described later in this document.
- Here's the same thing, using Python 2.4's decorator syntax::
-
- from django.contrib.auth.decorators import user_passes_test
-
- @user_passes_test(lambda u: u.has_perm('polls.can_vote'))
- def my_view(request):
- # ...
-
:func:`~django.contrib.auth.decorators.user_passes_test` takes a required
argument: a callable that takes a
:class:`~django.contrib.auth.models.User` object and returns ``True`` if
@@ -1093,7 +1068,7 @@
@user_passes_test(lambda u: u.has_perm('polls.can_vote'),
login_url='/login/')
def my_view(request):
- # ...
+ ...
The permission_required decorator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1107,9 +1082,9 @@
from django.contrib.auth.decorators import permission_required
+ permission_required('polls.can_vote')
def my_view(request):
- # ...
- my_view = permission_required('polls.can_vote')(my_view)
+ ...
As for the :meth:`User.has_perm` method, permission names take the form
``"<app label>.<permission codename>"`` (i.e. ``polls.can_vote`` for a
@@ -1120,9 +1095,9 @@
from django.contrib.auth.decorators import permission_required
+ permission_required('polls.can_vote', login_url='/loginpage/')
def my_view(request):
- # ...
- my_view = permission_required('polls.can_vote',
login_url='/loginpage/')(my_view)
+ ...
As in the :func:`~decorators.login_required` decorator, ``login_url``
defaults to :setting:`settings.LOGIN_URL <LOGIN_URL>`.
Modified: django/trunk/docs/topics/cache.txt
===================================================================
--- django/trunk/docs/topics/cache.txt 2010-02-09 15:02:39 UTC (rev 12399)
+++ django/trunk/docs/topics/cache.txt 2010-02-09 19:37:08 UTC (rev 12400)
@@ -332,13 +332,6 @@
from django.views.decorators.cache import cache_page
- def my_view(request):
- ...
-
- my_view = cache_page(my_view, 60 * 15)
-
-Or, using Python 2.4's decorator syntax::
-
@cache_page(60 * 15)
def my_view(request):
...
@@ -365,12 +358,9 @@
works in the same way as the ``CACHE_MIDDLEWARE_KEY_PREFIX`` setting for the
middleware. It can be used like this::
- my_view = cache_page(my_view, 60 * 15, key_prefix="site1")
-
-Or, using Python 2.4's decorator syntax::
-
@cache_page(60 * 15, key_prefix="site1")
def my_view(request):
+ ...
Specifying per-view cache in the URLconf
----------------------------------------
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.