Opened 15 years ago

Last modified 6 months ago

#13376 assigned New feature

Messages should have an "expire" flag

Reported by: ryanshow@… Owned by: Andy Miller
Component: contrib.messages Version: 1.2-beta
Severity: Normal Keywords: messages, expire
Cc: Ryan Cheley Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Messages should have a flag which sets their expiration behavior. In the current messages framework, messages are automatically expired as soon as they are iterated over. This can be overridden if you explicitly set their "used" flag to false after they have been iterated. It would be nice to be able to set a flag which tells the message never to expire unless explicitly told to do so.

Attachments (4)

messages_expirity_capabilities.1.diff (36.9 KB ) - added by marekw2143 14 years ago.
messages_expirity_capabilities.2.diff (35.8 KB ) - added by marekw2143 14 years ago.
messages_expirity_capabilities.3.diff (37.3 KB ) - added by marekw2143 14 years ago.
messages_expirity_capabilities.4.diff (35.7 KB ) - added by marekw2143 13 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by Russell Keith-Magee, 15 years ago

milestone: 1.3
Triage Stage: UnreviewedAccepted

Getting the right API will be important here, but I can see how the idea could be useful. Expiry based on time, number of displays, or some other request/user based flag could all be useful.

I've removed the 1.3 milestone because it's a feature request without a patch.

comment:2 by marekw2143, 14 years ago

Owner: changed from nobody to marekw2143
Status: newassigned

by marekw2143, 14 years ago

comment:3 by Bas Peschier, 14 years ago

Has patch: set

Pretty substantial patch, looks good at first sight, might take a deeper look soon.

comment:4 by Bas Peschier, 14 years ago

Needs documentation: set
Patch needs improvement: set

After inspection I have a couple of notes on the (otherwise good) patch:

  • I do not completely agree with the chosen api-functions on restrictions; on_iter and to_remove are too vague, I would use something along the lines of on_display since iteration could be happening at a lot of different points of time and is_expired to put more emphasis on the conceptual state (restriction expired) instead of the procedural state (we have to remove it).
  • The changes in the API must be documented so people can actually make use of restrictions without having to read code.
  • There are quite a few spelling errors and typos in the patch which give it a rushed feeling

comment:5 by Bas Peschier, 14 years ago

After going through the "storage" discussion on the mailing list, I looked a bit further into the patch and spotted something related which should be improved: at the moment the encoding is done centrally in storage/cookie.py with hardcoded checks for types. Maintaining different types of restrictions becomes a real pain in the backside this way. It should be de-centralised to the actual restriction class (which brings the problem of determining which restriction should be loaded for the decode).

by marekw2143, 14 years ago

by marekw2143, 14 years ago

comment:6 by Gabriel Hurley, 14 years ago

Component: Contrib appscontrib.messages

comment:7 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

by marekw2143, 13 years ago

comment:8 by marekw2143, 13 years ago

Easy pickings: unset
Owner: marekw2143 removed
Status: assignednew
UI/UX: unset

comment:9 by Andy Miller, 6 months ago

Owner: set to Andy Miller
Status: newassigned

comment:10 by Ryan Cheley, 6 months ago

Cc: Ryan Cheley added

comment:11 by Andy Miller, 6 months ago

Draft PR: https://github.com/django/django/pull/18286

I need to review the current code and the patch file as some did not apply at all (mostly in tests since they have moved in the last 13 years)
Docs need to be added (I need to research this and consider what needs to be added)

Then I think some feedback would be useful to know if the previous authors were on the right track and what more needs to be done.

comment:12 by Andy Miller, 6 months ago

I have decided to split this ticket into 2 PRs as per the discussion I started on the forum here: https://forum.djangoproject.com/t/ticket-13376-messages-should-have-an-expire-flag/32190

The first of the 2 PRs is here: https://github.com/django/django/pull/18332 which modifies the python API which would allow this ticket/patch to then be implemented as a third-party package with minimal changes.

comment:13 by Andy Miller, 6 months ago

Patch needs improvement: unset

comment:14 by Andy Miller, 6 months ago

Needs documentation: unset

comment:15 by Sarah Boyce, 6 months ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top