diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2009-12-09 16:57:23 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2009-12-09 16:57:23 +0000 |
| commit | 25020ddb05543fff1c37d77b49bd937fd2bbb170 (patch) | |
| tree | b156768f680819c54a73a2926b81d5d84d0e2205 /docs/ref/templates/api.txt | |
| parent | eeb10d5f2c5375ec28b7761f9ea0fd4f1d2e4bd1 (diff) | |
Fixed #4604 - Configurable message passing system, supporting anonymous users
This deprecates User.message_set in favour of a configurable messaging
system, with backends provided for cookie storage, session storage and
backward compatibility.
Many thanks to Tobias McNulty for the bulk of the work here, with
contributions from Chris Beaven (SmileyChris) and lots of code review from
Russell Keith-Magee, and input from many others. Also credit to the authors
of various messaging systems for Django whose ideas may have been pinched
:-)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/templates/api.txt')
| -rw-r--r-- | docs/ref/templates/api.txt | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 1b6eeb7014..077325b48e 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -311,7 +311,8 @@ and return a dictionary of items to be merged into the context. By default, ("django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", - "django.core.context_processors.media") + "django.core.context_processors.media", + "django.contrib.messages.context_processors.messages") .. versionadded:: 1.2 In addition to these, ``RequestContext`` always uses @@ -320,6 +321,10 @@ and return a dictionary of items to be merged into the context. By default, in case of accidental misconfiguration, it is deliberately hardcoded in and cannot be turned off by the :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting. +.. versionadded:: 1.2 + The ``'messages'`` context processor was added. For more information, see + the :ref:`messages documentation <ref-contrib-messages>`. + Each processor is applied in order. That means, if one processor adds a variable to the context and a second processor adds a variable with the same name, the second will override the first. The default processors are explained @@ -365,17 +370,18 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every logged-in user (or an ``AnonymousUser`` instance, if the client isn't logged in). - * ``messages`` -- A list of messages (as strings) for the currently - logged-in user. Behind the scenes, this calls - ``request.user.get_and_delete_messages()`` for every request. That method - collects the user's messages and deletes them from the database. - - Note that messages are set with ``user.message_set.create``. + * ``messages`` -- A list of messages (as strings) that have been set + via the :ref:`messages framework <ref-contrib-messages>`. * ``perms`` -- An instance of ``django.core.context_processors.PermWrapper``, representing the permissions that the currently logged-in user has. +.. versionchanged:: 1.2 + Prior to version 1.2, the ``messages`` variable was a lazy accessor for + ``user.get_and_delete_messages()``. It has been changed to include any + messages added via the :ref:`messages framework <ref-contrib-messages`. + django.core.context_processors.debug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -427,6 +433,25 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every :class:`~django.http.HttpRequest`. Note that this processor is not enabled by default; you'll have to activate it. +django.contrib.messages.context_processors.messages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every +``RequestContext`` will contain a single additional variable: + + * ``messages`` -- A list of messages (as strings) that have been set + via the user model (using ``user.message_set.create``) or through + the :ref:`messages framework <ref-contrib-messages>`. + +.. versionadded:: 1.2 + This template context variable was previously supplied by the ``'auth'`` + context processor. For backwards compatibility the ``'auth'`` context + processor will continue to supply the ``messages`` variable until Django + 1.4. If you use the ``messages`` variable, your project will work with + either (or both) context processors, but it is recommended to add + ``django.contrib.messages.context_processors.messages`` so your project + will be prepared for the future upgrade. + Writing your own context processors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
