django middleware: session backed messaging

This basically takes the ideas from the patches on ticket 4604 but puts them into middleware instead of aiming at a modification to core.

DjangoSnippet 1002

I added optional message type passing so you can display them differently.

notifications-example.png

  • Pingback: Bookmarks about Session

  • http://dpaste.com/112496/ Martin

    Thanks for the great work.
    Unfortunatelly I’m failing using yur snippet.
    Creating a message gives me: ‘WSGIRequest’ object has no attribute ‘notifications’

    notifications.py is located in:
    c:\Python25\Lib\site-packages\django\middleware

    I don’t need to import anything, do I? Any help would be greatly appreciated.

  • Martin

    Here’s my traceback. Put it in Website-field first time
    http://dpaste.com/112496/

  • Martin

    Sry, for the spamming….
    Problem was, that the folder was not part of my sys.path.
    But still I don’t get any messages in my template :(
    I’m using the exact code of your example, but the if-block is not entered. All I can get is something like

    when I use {{request.notifications}}
    Any advice? :(