On Jan 27, 4:52 pm, Matthias Julius <li...@julius-net.net> wrote:
> mvtango <martin.vir...@gmail.com> writes:
> > my users keep several browser windows open in my application, I need
> > to keep session information for all these windows separate. But I have
> > only one session object - modifying it while the user works in window
> > A and window B in parallel might get me in trouble if Request A and
> > Request B are under way in parallel.
>
> > So I thought about locking the session, modifiying it, saving it
> > during the request. I thought about locking the session at the
> > database level.
>
> > Questions: Anybody run into this? Would locking be the right way to do
> > it? Or are there any other ways of solving this?
Session data is stored in the database and the ORM. These transactions
are are threadsafe, so you won't run into conditions where browser A
overwrites the newly submitted data from browser B.
If you need to know know however whether browser A finished before
browser B and browser B had access to the complete transaction in
browser A, you are going to need to set up some logic that checks for
browser A's transaction being done before you allow browser B (i
recommend doing this in validation and not looping or waiting for some
condition).
Yet another way you can just be super sure is to set up only one
thread and process on your server. This will force the tranactions to
excute in order, but the trade off is speed and flexiblity. Your best
bet is just to program without needing context from browser A's
session to be completed before browser B's.
--~--~---------~--~----~------------~-------~--~----~
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
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---