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
This commit is contained in:
Luke Plant 2009-12-09 16:57:23 +00:00
parent eeb10d5f2c
commit 25020ddb05
40 changed files with 2100 additions and 29 deletions

View file

@ -23,6 +23,9 @@ The auth system consists of:
user.
* Messages: A simple way to queue messages for given users.
.. deprecated:: 1.2
The Messages component of the auth system will be removed in Django 1.4.
Installation
============
@ -1289,6 +1292,11 @@ messages.
Messages
========
.. deprecated:: 1.2
This functionality will be removed in Django 1.4. You should use the
:ref:`messages framework <ref-contrib-messages>` for all new projects and
begin to update your existing code immediately.
The message system is a lightweight way to queue messages for given users.
A message is associated with a :class:`~django.contrib.auth.models.User`.
@ -1334,13 +1342,16 @@ logged-in user and his/her messages are made available in the
</ul>
{% endif %}
Note that :class:`~django.template.context.RequestContext` calls
:meth:`~django.contrib.auth.models.User.get_and_delete_messages` behind the
scenes, so any messages will be deleted even if you don't display them.
.. versionchanged:: 1.2
The ``messages`` template variable uses a backwards compatible method in the
:ref:`messages framework <ref-contrib-messages>` to retrieve messages from
both the user ``Message`` model and from the new framework. Unlike in
previous revisions, the messages will not be erased unless they are actually
displayed.
Finally, note that this messages framework only works with users in the user
database. To send messages to anonymous users, use the
:ref:`session framework <topics-http-sessions>`.
:ref:`messages framework <ref-contrib-messages>`.
.. _authentication-backends: