Acctually,

I need to do a SELECT in a table. In this table has a flag field. if the
flag field has 0 so I can update de flag field to 1.
In other words I need to do a SELECT by verifing if the flag field is 0. And
after, I can update to 1 the flag field.

But the problem is: More than one access occurr in this table.

Imagine A and B (two users) accessing this table.
A do a SELECT.
B do a SELECT.
A verify that the flag field is 0.
B verify that the flag field is 0.
A UPDATE to 1 the flag field.
B UPTADE to 1 the flag field.  (Wrong!! B couldn't  set the flag to 1
because the flag already was configured to 1.)

But B must to wait for A. A need to put the flag in 0 again. So B can put
the flag in 1 and use the datas.

is there a way to resolve this problem in django?? Can put some example?

thanks

On Wed, Sep 30, 2009 at 10:05 AM, Kristaps Kūlis
<kristaps.ku...@gmail.com>wrote:

> Create locks and store them at cache as keys.
> Or implement counter as cache.incr('users_online')
>
>
> On Wed, Sep 30, 2009 at 3:52 AM, Nan <ringe...@gmail.com> wrote:
>
>>
>> Any particular reason you can't just use User.objects.count() ?
>>
>> On Sep 29, 7:16 pm, gustavo Cardoso <gnasce...@gmail.com> wrote:
>> > Hello Folks,
>> >
>> > I need to implement a Counter.
>> > One variable to store the number of users in my site.
>> > This variable can't be access in the same time for more than one user.
>> > How I do this in django. How I create a method that only one user can
>> access
>> > in the same time?
>> > Is there some API to lock and release that variable?
>> > Thanks!
>> >
>> > --
>> > Gustavo Nascente Cardoso
>> > Ciência da Computação - UFES
>>
>>
>
> >
>


-- 
Gustavo Nascente Cardoso
Ciência da Computação - UFES

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

Reply via email to