On Sun, Mar 30, 2008 at 8:45 AM, PENPEN <[EMAIL PROTECTED]> wrote: > > Hi Carl, > I didn't mention to the syncdb of manage.py. > I'm talking about the problem that may happen when trying to access > the db. > > Take a poll for exmaple. It may happen that 2 users vote at the same > time. A vote action is made in the three steps: > 1. read the old counter > 2. add the counter by 1 > 3. save the counter > > I denote the two users as A and B, and A1 means the 1st step of A's > progress, and B2 means the 2nd step of B, etc. > > I don't know how django deal with the requests of A and B. I suppose > they are independent. So I think the scenario may happen like this: > A1 B1 A2 A3 B2 B3 > or > A1 A2 A3 B1 B2 B3 > or others > > If B1 happens after A3, there is no problem, and the counter is > increased by 2. But if B1 is before A3, then B will read the old value > again. And at last, the counter is only increased by 1, not 2. > > That's my concern. So how Django handle with such case? Many thanks!
Django allows you to hook into your database's underlying transaction support: http://www.djangoproject.com/documentation/transactions/ Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---