Hi!

I've hit a small dilemma! I have a handler called vote, when it is
invoked it sets a user's vote to whatever they have picked. To
remember what options they previously picked, I store a VoteRecord
options which details what their current vote is set to.

Of course, the first time they vote, I have to create the object and
store it. But successive votes should just change the value of the
existing VoteRecord. But he comes the problem: under some
circumstances two VoteRecords can be created. It's rare (only happened
once in all 541 votes we've seen so far) but still bad when it does.

The issue happens because two separate handlers both do essentially
this:

vote = VoteRecord.all().filter('user =', user)
if vote.count(1) == 0:
    obj = VoteRecord()
    obj.user = user
    obj.option = option
    obj.put()
else:
    obj = vote[0]
    obj.option = option
    obj.put()

My question is: what is the most effective and fastest way to handle
these requests while ensuring that no request is lost and no request
creates two VoteRecord objects?

Thanks,
Larry

PS: You can see the polls working here: http://silicon.appspot.com/polls.
Notice that voting twice should change the vote the second time
instead of creating two votes.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to