Hi,

Using the latest SVN revision, I have an issue when manipulating
sessions (out of request).

The background:
My application stores custom user privileges in their sessions (home-
cooked version of 'per-object' permissions).
When specific conditions are met, I must 'refresh' some user sessions.

Here is my faulty code (based on a refresh of all sessions, for
simplicity here):
from django.contrib.sessions.models import Session
for session in Session.objects.all():
    session['privileges'] = "foo"

And this barks the following error message:
'Session' object does not support item assignment

I had a look at the session documentation. If one misses one of the
first lines (like I did), it can lead to a mess (like I have :-) ):
"Sessions are implemented via a piece of middleware and a Django
model".
And indeed, sessions appear clean and developer-friendly in the
documentation, because they have gone through the middleware piece
(thanks to the SessionWrapper).

Now back to my problem:
* Are Django sessions only designed to be used through the request
context (and session middleware) ?
* Is there any "easy" snippet of code to do what I want (i.e update a
Session object out of view) ?
* Do you think the documentation could benefit more precision, to
highlight the real distinction between "session" and
"request.session" ? (I was tricked by the whole thing, thinking that
sessions could be updated as easily out of the view)

Thanks for your feedback.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to