On 6/16/07, Vertigo <[EMAIL PROTECTED]> wrote:
> * Are Django sessions only designed to be used through the request
> context (and session middleware) ?

No, but they're most convenient that way.

> * Is there any "easy" snippet of code to do what I want (i.e update a
> Session object out of view) ?

This should do; the key point is that session_data is a pickled
dictionary.  The Session Middleware takes care of deserializing and
serializing as a convenience, but since you're not using it, you'll
have to do the extra bits yourself.

Make sure not to do this on a live DB at first, since I haven't tested it.  :)

for session in Session.objects.all():
   d = session.get_decoded()
   d['privileges'] = "foo"
   session.session_data = Session.objects.encode(d)
   session.save()

Another spelling would be this:

for session in Session.objects.all():
   d = session.get_decoded()
   d['privileges'] = "foo"
   Session.objects.save(session.session_key, d, session.expire_date)

> * 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)

Yes.  Can you open a documentation ticket on this, ideally with some
suggested verbiage?

--~--~---------~--~----~------------~-------~--~----~
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